@swishapp/sdk 0.55.0 → 0.56.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 +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/intents/handlers/create-item-handler.d.ts +29 -0
- package/dist/intents/handlers/create-list-handler.d.ts +13 -0
- package/dist/intents/handlers/delete-item-handler.d.ts +18 -0
- package/dist/intents/handlers/delete-list-handler.d.ts +18 -0
- package/dist/intents/handlers/edit-item-lists-handler.d.ts +25 -0
- package/dist/intents/handlers/edit-item-variant-handler.d.ts +28 -0
- package/dist/intents/handlers/edit-list-handler.d.ts +19 -0
- package/dist/intents/handlers/open-home-handler.d.ts +10 -0
- package/dist/intents/handlers/open-list-menu-handler.d.ts +18 -0
- package/dist/intents/handlers/open-sign-in-handler.d.ts +16 -0
- package/dist/intents/hooks/after-create-item-hook.d.ts +6 -0
- package/dist/intents/hooks/after-edit-item-lists-hook.d.ts +6 -0
- package/dist/intents/intent-handler.d.ts +10 -0
- package/dist/intents/intent-hook.d.ts +9 -0
- package/dist/intents/intents.d.ts +21 -0
- package/dist/intents/types.d.ts +70 -0
- package/dist/state/index.d.ts +1 -1
- package/dist/state/item-context-signal.d.ts +0 -2
- package/dist/state/item-state-signal.d.ts +2 -2
- package/dist/storefront-api/load-save-intent-data.d.ts +12 -0
- package/dist/storefront-api/queries/fragments.d.ts +3 -2
- package/dist/storefront-api/queries/index.d.ts +10 -8
- package/dist/storefront-api/storefront-api-client.d.ts +8 -3
- package/dist/storefront-api/types/storefront.generated.d.ts +66 -16
- package/dist/swish-ui/swish-ui-utils.d.ts +31 -29
- package/dist/swish.d.ts +9 -39
- package/dist/swish.js +113 -58
- package/dist/utils/shopify-gid.d.ts +2 -2
- package/package.json +3 -2
package/dist/dom/dom-utils.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export interface CreateElementLocatorArgs {
|
|
|
7
7
|
export declare function createElementLocator({ onElementFound, selector, observerOptions, }: CreateElementLocatorArgs): MutationObserver;
|
|
8
8
|
export interface CreateLocationObserverArgs {
|
|
9
9
|
onLocationChange: (location: Location) => void;
|
|
10
|
+
fireOnInit?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare function createLocationObserver({ onLocationChange, }: CreateLocationObserverArgs): () => void;
|
|
12
|
+
export declare function createLocationObserver({ onLocationChange, fireOnInit, }: CreateLocationObserverArgs): () => void;
|
|
12
13
|
export interface CreateHrefObserverArgs {
|
|
13
14
|
element: HTMLAnchorElement;
|
|
14
15
|
onHrefChange: (href: string) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type * from "@swishapp/api-client";
|
|
|
2
2
|
export type * from "./ajax-api/ajax-api-client";
|
|
3
3
|
export type { EventName } from "./events/event-bus";
|
|
4
4
|
export type * from "./storefront-api/storefront-api-client";
|
|
5
|
+
export type * from "./intents/types";
|
|
5
6
|
export { SwishApp } from "./swish";
|
|
6
7
|
export type { Ref, SwishUiElement } from "./swish-ui/swish-ui-element";
|
|
7
8
|
export type { Toast, ToastManager, UnsaveAlertSubmitData, ListSelectSubmitData, VariantSelectSubmitData, UnsaveAlertOptions, ListSelectOptions, VariantSelectOptions, } from "./swish-ui/swish-ui-utils";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Item } from "@swishapp/api-client";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { GetSaveIntentDataQuery, GetSaveIntentDataWithVariantQuery } from "../../storefront-api/storefront-api-client";
|
|
4
|
+
import { IntentHandler } from "../intent-handler";
|
|
5
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
6
|
+
export declare const CreateItemIntentDataSchema: v.ObjectSchema<{
|
|
7
|
+
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>]>;
|
|
8
|
+
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>;
|
|
9
|
+
readonly quantity: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>;
|
|
10
|
+
readonly tags: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
11
|
+
}, undefined>;
|
|
12
|
+
export interface CreateItemIntent extends IntentBase {
|
|
13
|
+
action: "create";
|
|
14
|
+
type: "swish/Item";
|
|
15
|
+
data: CreateItemIntentData;
|
|
16
|
+
}
|
|
17
|
+
export interface CreateItemIntentData extends Omit<CreateItemIntentDataValidated, "productId" | "variantId"> {
|
|
18
|
+
productId: number | string;
|
|
19
|
+
variantId?: number | string;
|
|
20
|
+
}
|
|
21
|
+
export type CreateItemIntentDataValidated = v.InferOutput<typeof CreateItemIntentDataSchema>;
|
|
22
|
+
export type CreateItemSuccessResponse = SuccessIntentResponse<{
|
|
23
|
+
item: Item;
|
|
24
|
+
product: GetSaveIntentDataQuery["product"];
|
|
25
|
+
variant: GetSaveIntentDataWithVariantQuery["variant"];
|
|
26
|
+
}>;
|
|
27
|
+
export declare class CreateItemHandler extends IntentHandler<CreateItemIntent> {
|
|
28
|
+
invoke(intent: CreateItemIntent): Promise<IntentResponse<CreateItemIntent>>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { List } from "@swishapp/api-client";
|
|
2
|
+
import { IntentHandler } from "../intent-handler";
|
|
3
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
+
export interface CreateListIntent extends IntentBase {
|
|
5
|
+
action: "create";
|
|
6
|
+
type: "swish/List";
|
|
7
|
+
}
|
|
8
|
+
export type CreateListSuccessResponse = SuccessIntentResponse<{
|
|
9
|
+
list: List;
|
|
10
|
+
}>;
|
|
11
|
+
export declare class CreateListHandler extends IntentHandler<CreateListIntent> {
|
|
12
|
+
invoke(intent: CreateListIntent): Promise<IntentResponse<CreateListIntent>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { IntentHandler } from "../intent-handler";
|
|
3
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
+
export declare const DeleteItemIntentDataSchema: v.ObjectSchema<{
|
|
5
|
+
readonly itemId: v.StringSchema<undefined>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export interface DeleteItemIntent extends IntentBase {
|
|
8
|
+
action: "delete";
|
|
9
|
+
type: "swish/Item";
|
|
10
|
+
data: DeleteItemIntentData;
|
|
11
|
+
}
|
|
12
|
+
export type DeleteItemIntentData = v.InferOutput<typeof DeleteItemIntentDataSchema>;
|
|
13
|
+
export type DeleteItemSuccessResponse = SuccessIntentResponse<{
|
|
14
|
+
itemId: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare class DeleteItemHandler extends IntentHandler<DeleteItemIntent> {
|
|
17
|
+
invoke(intent: DeleteItemIntent): Promise<IntentResponse<DeleteItemIntent>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { IntentHandler } from "../intent-handler";
|
|
3
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
+
export declare const DeleteListIntentDataSchema: v.ObjectSchema<{
|
|
5
|
+
readonly listId: v.StringSchema<undefined>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export interface DeleteListIntent extends IntentBase {
|
|
8
|
+
action: "delete";
|
|
9
|
+
type: "swish/List";
|
|
10
|
+
data: DeleteListIntentData;
|
|
11
|
+
}
|
|
12
|
+
export type DeleteListIntentData = v.InferOutput<typeof DeleteListIntentDataSchema>;
|
|
13
|
+
export type DeleteListSuccessResponse = SuccessIntentResponse<{
|
|
14
|
+
listId: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare class DeleteListHandler extends IntentHandler<DeleteListIntent> {
|
|
17
|
+
invoke(intent: DeleteListIntent): Promise<IntentResponse<DeleteListIntent>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ItemDetail } from "@swishapp/api-client";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { GetSaveIntentDataQuery, GetSaveIntentDataWithVariantQuery } from "../../storefront-api/storefront-api-client";
|
|
4
|
+
import { IntentHandler } from "../intent-handler";
|
|
5
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
6
|
+
import { DeleteItemIntent } from "./delete-item-handler";
|
|
7
|
+
export declare const EditItemListsIntentDataSchema: v.ObjectSchema<{
|
|
8
|
+
readonly itemId: v.StringSchema<undefined>;
|
|
9
|
+
}, undefined>;
|
|
10
|
+
export interface EditItemListsIntent extends IntentBase {
|
|
11
|
+
action: "edit";
|
|
12
|
+
type: "swish/ItemLists";
|
|
13
|
+
data: EditItemListsIntentData;
|
|
14
|
+
}
|
|
15
|
+
export interface EditItemListsIntentData extends EditItemListsIntentDataValidated {
|
|
16
|
+
}
|
|
17
|
+
export type EditItemListsSuccessResponse = SuccessIntentResponse<{
|
|
18
|
+
item: ItemDetail;
|
|
19
|
+
product: GetSaveIntentDataQuery["product"];
|
|
20
|
+
variant: GetSaveIntentDataWithVariantQuery["variant"];
|
|
21
|
+
}>;
|
|
22
|
+
export type EditItemListsIntentDataValidated = v.InferOutput<typeof EditItemListsIntentDataSchema>;
|
|
23
|
+
export declare class EditItemListsHandler extends IntentHandler<EditItemListsIntent> {
|
|
24
|
+
invoke(intent: EditItemListsIntent, skipEvents?: boolean): Promise<IntentResponse<EditItemListsIntent | DeleteItemIntent>>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Item } from "@swishapp/api-client";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { GetSaveIntentDataQuery, GetSaveIntentDataWithVariantQuery } from "../../storefront-api/storefront-api-client";
|
|
4
|
+
import { IntentHandler } from "../intent-handler";
|
|
5
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
6
|
+
export declare const EditItemVariantIntentDataSchema: v.ObjectSchema<{
|
|
7
|
+
readonly itemId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>]>, undefined>;
|
|
8
|
+
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>]>;
|
|
9
|
+
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<string | number, number>, v.NumberSchema<undefined>]>, undefined>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
export interface EditItemVariantIntent extends IntentBase {
|
|
12
|
+
action: "edit";
|
|
13
|
+
type: "swish/ItemVariant";
|
|
14
|
+
data: EditItemVariantIntentData;
|
|
15
|
+
}
|
|
16
|
+
export interface EditItemVariantIntentData extends Omit<EditItemVariantIntentDataValidated, "productId" | "variantId"> {
|
|
17
|
+
productId: number | string;
|
|
18
|
+
variantId?: number | string;
|
|
19
|
+
}
|
|
20
|
+
export type EditItemVariantIntentDataValidated = v.InferOutput<typeof EditItemVariantIntentDataSchema>;
|
|
21
|
+
export type EditItemVariantSuccessResponse = SuccessIntentResponse<{
|
|
22
|
+
item: Item;
|
|
23
|
+
product: GetSaveIntentDataQuery["product"];
|
|
24
|
+
variant: GetSaveIntentDataWithVariantQuery["variant"];
|
|
25
|
+
}>;
|
|
26
|
+
export declare class EditItemVariantHandler extends IntentHandler<EditItemVariantIntent> {
|
|
27
|
+
invoke(intent: EditItemVariantIntent, skipEvents?: boolean): Promise<IntentResponse<EditItemVariantIntent>>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { List } from "@swishapp/api-client";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { IntentHandler } from "../intent-handler";
|
|
4
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
5
|
+
export declare const EditListIntentDataSchema: v.ObjectSchema<{
|
|
6
|
+
readonly listId: v.StringSchema<undefined>;
|
|
7
|
+
}, undefined>;
|
|
8
|
+
export interface EditListIntent extends IntentBase {
|
|
9
|
+
action: "edit";
|
|
10
|
+
type: "swish/List";
|
|
11
|
+
data: EditListIntentData;
|
|
12
|
+
}
|
|
13
|
+
export type EditListIntentData = v.InferOutput<typeof EditListIntentDataSchema>;
|
|
14
|
+
export type EditListSuccessResponse = SuccessIntentResponse<{
|
|
15
|
+
list: List;
|
|
16
|
+
}>;
|
|
17
|
+
export declare class EditListHandler extends IntentHandler<EditListIntent> {
|
|
18
|
+
invoke(intent: EditListIntent): Promise<IntentResponse<EditListIntent>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IntentHandler } from "../intent-handler";
|
|
2
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
3
|
+
export interface OpenHomeIntent extends IntentBase {
|
|
4
|
+
action: "open";
|
|
5
|
+
type: "swish/Home";
|
|
6
|
+
}
|
|
7
|
+
export type OpenHomeSuccessResponse = SuccessIntentResponse<void>;
|
|
8
|
+
export declare class OpenHomeHandler extends IntentHandler<OpenHomeIntent> {
|
|
9
|
+
invoke(intent: OpenHomeIntent): Promise<IntentResponse<OpenHomeIntent>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { IntentHandler } from "../intent-handler";
|
|
3
|
+
import { IntentBase, IntentResponse } from "../types";
|
|
4
|
+
import { EditListSuccessResponse } from "./edit-list-handler";
|
|
5
|
+
import { DeleteListSuccessResponse } from "./delete-list-handler";
|
|
6
|
+
export declare const OpenListMenuIntentDataSchema: v.ObjectSchema<{
|
|
7
|
+
readonly listId: v.StringSchema<undefined>;
|
|
8
|
+
}, undefined>;
|
|
9
|
+
export interface OpenListMenuIntent extends IntentBase {
|
|
10
|
+
action: "open";
|
|
11
|
+
type: "swish/ListMenu";
|
|
12
|
+
data: OpenListMenuIntentData;
|
|
13
|
+
}
|
|
14
|
+
export type OpenListMenuIntentData = v.InferOutput<typeof OpenListMenuIntentDataSchema>;
|
|
15
|
+
export type OpenListMenuSuccessResponse = EditListSuccessResponse | DeleteListSuccessResponse;
|
|
16
|
+
export declare class OpenListMenuHandler extends IntentHandler<OpenListMenuIntent> {
|
|
17
|
+
invoke(intent: OpenListMenuIntent): Promise<IntentResponse<OpenListMenuIntent>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { IntentHandler } from "../intent-handler";
|
|
3
|
+
import { IntentBase, IntentResponse, SuccessIntentResponse } from "../types";
|
|
4
|
+
export declare const OpenSignInIntentDataSchema: v.ObjectSchema<{
|
|
5
|
+
readonly returnTo: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export interface OpenSignInIntent extends IntentBase {
|
|
8
|
+
action: "open";
|
|
9
|
+
type: "swish/SignIn";
|
|
10
|
+
data: OpenSignInIntentData;
|
|
11
|
+
}
|
|
12
|
+
export type OpenSignInIntentData = v.InferOutput<typeof OpenSignInIntentDataSchema>;
|
|
13
|
+
export type OpenSignInSuccessResponse = SuccessIntentResponse<void>;
|
|
14
|
+
export declare class OpenSignInHandler extends IntentHandler<OpenSignInIntent> {
|
|
15
|
+
invoke(intent: OpenSignInIntent): Promise<IntentResponse<OpenSignInIntent>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CreateItemIntent } from "../handlers/create-item-handler";
|
|
2
|
+
import { IntentHook } from "../intent-hook";
|
|
3
|
+
import { IntentResponse } from "../types";
|
|
4
|
+
export declare class AfterCreateItemHook extends IntentHook<CreateItemIntent> {
|
|
5
|
+
invoke(response: IntentResponse<CreateItemIntent>): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EditItemListsIntent } from "../handlers/edit-item-lists-handler";
|
|
2
|
+
import { IntentHook } from "../intent-hook";
|
|
3
|
+
import { IntentResponse } from "../types";
|
|
4
|
+
export declare class AfterEditItemListsHook extends IntentHook<EditItemListsIntent> {
|
|
5
|
+
invoke(response: IntentResponse<EditItemListsIntent>): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SwishApp } from "../swish";
|
|
2
|
+
import { IntentOptions } from "./intents";
|
|
3
|
+
import { Intent, IntentEventBus, IntentResponse } from "./types";
|
|
4
|
+
export declare abstract class IntentHandler<T extends Intent = Intent> {
|
|
5
|
+
protected readonly swish: SwishApp;
|
|
6
|
+
protected readonly eventBus: IntentEventBus;
|
|
7
|
+
protected readonly options: IntentOptions;
|
|
8
|
+
constructor(swish: SwishApp, eventBus: IntentEventBus, options: IntentOptions);
|
|
9
|
+
abstract invoke(intent: T): Promise<IntentResponse<T>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SwishApp } from "../swish";
|
|
2
|
+
import { IntentOptions } from "./intents";
|
|
3
|
+
import { Intent, IntentResponse } from "./types";
|
|
4
|
+
export declare abstract class IntentHook<T extends Intent = Intent> {
|
|
5
|
+
protected readonly swish: SwishApp;
|
|
6
|
+
protected readonly options: IntentOptions;
|
|
7
|
+
constructor(swish: SwishApp, options: IntentOptions);
|
|
8
|
+
abstract invoke(respomse: IntentResponse<T>): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SwishApp } from "../swish";
|
|
2
|
+
import { Intent, IntentActivity, IntentQuery, IntentQueryWithParams, IntentResponse } from "./types";
|
|
3
|
+
export interface IntentOptions {
|
|
4
|
+
allowSaveWithoutVariant?: boolean;
|
|
5
|
+
deleteSavedItemsWithoutEdit?: boolean;
|
|
6
|
+
showToastAfterSave?: boolean;
|
|
7
|
+
showToastAfterDelete?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class Intents {
|
|
10
|
+
private readonly swish;
|
|
11
|
+
private readonly eventBus;
|
|
12
|
+
private readonly options;
|
|
13
|
+
constructor(swish: SwishApp, options: IntentOptions);
|
|
14
|
+
invoke<T extends Intent>(intent: T): Promise<IntentActivity<T>>;
|
|
15
|
+
listen(intent: Pick<Intent, "action" | "type">, callback: (response: IntentResponse) => void): () => void;
|
|
16
|
+
getIntentQuery(intent: Pick<Intent, "action" | "type">): IntentQuery;
|
|
17
|
+
parseIntent(intent: Intent | IntentQuery | IntentQueryWithParams): Intent;
|
|
18
|
+
handleIntent<T extends Intent>(intent: T): Promise<IntentResponse<T>>;
|
|
19
|
+
initIntentHooks(): void;
|
|
20
|
+
initIntentWatcher(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { CreateItemIntent, CreateItemSuccessResponse } from "./handlers/create-item-handler";
|
|
2
|
+
import { DeleteItemIntent, DeleteItemSuccessResponse } from "./handlers/delete-item-handler";
|
|
3
|
+
import { EditItemVariantIntent, EditItemVariantSuccessResponse } from "./handlers/edit-item-variant-handler";
|
|
4
|
+
import { EditItemListsIntent, EditItemListsSuccessResponse } from "./handlers/edit-item-lists-handler";
|
|
5
|
+
import { EditListIntent, EditListSuccessResponse } from "./handlers/edit-list-handler";
|
|
6
|
+
import { DeleteListIntent, DeleteListSuccessResponse } from "./handlers/delete-list-handler";
|
|
7
|
+
import { CreateListIntent, CreateListSuccessResponse } from "./handlers/create-list-handler";
|
|
8
|
+
import { OpenHomeIntent, OpenHomeSuccessResponse } from "./handlers/open-home-handler";
|
|
9
|
+
import { OpenListMenuIntent, OpenListMenuSuccessResponse } from "./handlers/open-list-menu-handler";
|
|
10
|
+
import { OpenSignInIntent, OpenSignInSuccessResponse } from "./handlers/open-sign-in-handler";
|
|
11
|
+
export type { DeleteItemSuccessResponse, EditItemVariantSuccessResponse, EditItemListsSuccessResponse, CreateItemSuccessResponse, EditListSuccessResponse, DeleteListSuccessResponse, CreateListSuccessResponse, };
|
|
12
|
+
export type IntentAction = "create" | "edit" | "delete" | "open";
|
|
13
|
+
export type IntentType = "swish/Item" | "swish/ItemVariant" | "swish/ItemLists" | "swish/List" | "swish/Home" | "swish/ListMenu" | "swish/SignIn";
|
|
14
|
+
export type IntentQuery = `${IntentAction}:${IntentType}`;
|
|
15
|
+
export type IntentQueryParam = `${string}=${string}`;
|
|
16
|
+
export type IntentQueryWithParams = `${IntentQuery},${IntentQueryParam}`;
|
|
17
|
+
export type Intent = CreateItemIntent | EditItemVariantIntent | EditItemListsIntent | DeleteItemIntent | EditListIntent | DeleteListIntent | CreateListIntent | OpenHomeIntent | OpenListMenuIntent | OpenSignInIntent;
|
|
18
|
+
export type IntentResponse<I extends Intent = Intent> = ClosedIntentResponse | ErrorIntentResponse | IntentToSuccessResponse<I>;
|
|
19
|
+
export type IntentQueryResponse<I extends IntentQuery = IntentQuery> = ClosedIntentResponse | ErrorIntentResponse | IntentQueryToSuccessResponse<I>;
|
|
20
|
+
export type IntentResponseEvent<I extends IntentQuery = IntentQuery> = CustomEvent<IntentQueryResponse<I>>;
|
|
21
|
+
export interface IntentActivity<I extends Intent = Intent> {
|
|
22
|
+
intent: I;
|
|
23
|
+
complete: Promise<IntentResponse<I>>;
|
|
24
|
+
}
|
|
25
|
+
export interface IntentResponseBase {
|
|
26
|
+
code: "ok" | "error" | "closed";
|
|
27
|
+
}
|
|
28
|
+
export interface ClosedIntentResponse extends IntentResponseBase {
|
|
29
|
+
code: "closed";
|
|
30
|
+
}
|
|
31
|
+
export interface ErrorIntentResponse extends IntentResponseBase {
|
|
32
|
+
code: "error";
|
|
33
|
+
message: string;
|
|
34
|
+
issues: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface SuccessIntentResponse<T> extends IntentResponseBase {
|
|
37
|
+
code: "ok";
|
|
38
|
+
data: T;
|
|
39
|
+
}
|
|
40
|
+
export interface IntentBase {
|
|
41
|
+
action: IntentAction;
|
|
42
|
+
type: IntentType;
|
|
43
|
+
data?: unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface IntentSuccessResponseMap {
|
|
46
|
+
"create:swish/Item": CreateItemSuccessResponse;
|
|
47
|
+
"edit:swish/ItemVariant": EditItemVariantSuccessResponse;
|
|
48
|
+
"edit:swish/ItemLists": EditItemListsSuccessResponse | DeleteItemSuccessResponse;
|
|
49
|
+
"delete:swish/Item": DeleteItemSuccessResponse;
|
|
50
|
+
"edit:swish/List": EditListSuccessResponse;
|
|
51
|
+
"delete:swish/List": DeleteListSuccessResponse;
|
|
52
|
+
"create:swish/List": CreateListSuccessResponse;
|
|
53
|
+
"open:swish/Home": OpenHomeSuccessResponse;
|
|
54
|
+
"open:swish/ListMenu": OpenListMenuSuccessResponse;
|
|
55
|
+
"open:swish/SignIn": OpenSignInSuccessResponse;
|
|
56
|
+
}
|
|
57
|
+
export type IntentToSuccessResponse<I extends {
|
|
58
|
+
action: IntentAction;
|
|
59
|
+
type: IntentType;
|
|
60
|
+
}> = I extends {
|
|
61
|
+
action: infer A;
|
|
62
|
+
type: infer T;
|
|
63
|
+
} ? `${Extract<A, string>}:${Extract<T, string>}` extends keyof IntentSuccessResponseMap ? IntentSuccessResponseMap[`${Extract<A, string>}:${Extract<T, string>}`] : never : never;
|
|
64
|
+
export type IntentQueryToSuccessResponse<I extends IntentQuery = IntentQuery> = I extends keyof IntentSuccessResponseMap ? IntentSuccessResponseMap[I] : never;
|
|
65
|
+
export type IntentResposeEvent = CustomEvent<IntentResponse>;
|
|
66
|
+
export interface IntentEventBus {
|
|
67
|
+
addEventListener<I extends IntentQuery = IntentQuery>(type: I, callback: (event: IntentResponseEvent<I>) => void): void;
|
|
68
|
+
removeEventListener(type: IntentQuery, callback: (event: IntentResposeEvent) => void): void;
|
|
69
|
+
dispatchEvent(event: IntentResponseEvent): boolean;
|
|
70
|
+
}
|
package/dist/state/index.d.ts
CHANGED
|
@@ -5,7 +5,5 @@ export interface ItemContext {
|
|
|
5
5
|
productId?: string;
|
|
6
6
|
variantId?: string;
|
|
7
7
|
itemId?: string;
|
|
8
|
-
skipVariantSelect?: boolean;
|
|
9
|
-
defaultVariantId?: string;
|
|
10
8
|
}
|
|
11
9
|
export declare const itemContextSignal: (swish: SwishApp) => (source?: HTMLElement) => import("@preact/signals-core").Signal<ItemContext>;
|
|
@@ -13,7 +13,7 @@ export declare const itemStateSignal: (swish: SwishApp) => (context: Signal<Item
|
|
|
13
13
|
unsaving: boolean;
|
|
14
14
|
}> & {
|
|
15
15
|
save: () => Promise<void>;
|
|
16
|
-
unsave: () => void
|
|
17
|
-
update: () => void
|
|
16
|
+
unsave: () => Promise<void>;
|
|
17
|
+
update: () => Promise<void>;
|
|
18
18
|
toggle: () => Promise<void>;
|
|
19
19
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StorefrontApiClient } from "./storefront-api-client";
|
|
2
|
+
import type { GetSaveIntentDataQuery, GetSaveIntentDataWithVariantQuery } from "./types/storefront.generated";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
export declare const LoadSaveIntentDataSchema: v.ObjectSchema<{
|
|
5
|
+
readonly productId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>;
|
|
6
|
+
readonly variantId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string>]>, undefined>;
|
|
7
|
+
}, undefined>;
|
|
8
|
+
export type LoadSaveIntentDataArgs = v.InferOutput<typeof LoadSaveIntentDataSchema>;
|
|
9
|
+
export declare const loadSaveIntentData: (client: StorefrontApiClient, args: LoadSaveIntentDataArgs) => Promise<{
|
|
10
|
+
data: GetSaveIntentDataQuery | GetSaveIntentDataWithVariantQuery | undefined;
|
|
11
|
+
errors: import("@shopify/graphql-client").ResponseErrors | null;
|
|
12
|
+
}>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const PRODUCT_IMAGE_FIELDS = "\n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n";
|
|
2
|
+
export declare const SAVE_INTENT_DATA_FIELDS = "\n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n";
|
|
2
3
|
export declare const PRODUCT_CARD_DATA_FIELDS = "\n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n";
|
|
3
4
|
export declare const PRODUCT_VARIANT_DATA_FIELDS = "\n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n";
|
|
4
5
|
export declare const PRODUCT_OPTIONS_VARIANT_FIELDS = "\n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n";
|
|
5
|
-
export declare const SELECTED_VARIANT_FIELDS = "\n fragment selectedVariantFields on Product {\n id\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n";
|
|
6
|
-
export declare const PRODUCT_OPTIONS_FIELDS = "\n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n";
|
|
6
|
+
export declare const SELECTED_VARIANT_FIELDS = "\n fragment selectedVariantFields on Product {\n id\n availableForSale\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n";
|
|
7
|
+
export declare const PRODUCT_OPTIONS_FIELDS = "\n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n";
|
|
7
8
|
export declare const PRODUCT_IMAGES_FIELDS = "\n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n";
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
export declare const GET_SAVE_INTENT_DATA_BY_ID = "\n query GetSaveIntentData(\n $productId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...saveIntentProductFields\n }\n }\n \n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
2
|
+
export declare const GET_SAVE_INTENT_DATA_BY_ID_WITH_VARIANT = "\n query GetSaveIntentDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...saveIntentProductFields\n }\n variant: node(id: $variantId) {\n ...saveIntentVariantFields\n }\n }\n \n fragment saveIntentProductFields on Product {\n id\n availableForSale\n featuredImage {\n ...productImageFields\n }\n handle\n title\n variantsCount {\n count\n }\n selectedOrFirstAvailableVariant {\n ...saveIntentVariantFields\n }\n }\n fragment saveIntentVariantFields on ProductVariant {\n id\n availableForSale\n currentlyNotInStock\n image {\n ...productImageFields\n }\n title\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
1
3
|
export declare const GET_PRODUCT_CARD_DATA_BY_ID = "\n query GetProductCardData(\n $productId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
2
4
|
export declare const GET_PRODUCT_CARD_DATA_BY_ID_WITH_VARIANT = "\n query GetProductCardDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n }\n variant: node(id: $variantId) {\n ...productVariantDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
3
|
-
export declare const GET_PRODUCT_OPTIONS_BY_ID = "\n query GetProductOptions(\n $productId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productOptionsFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
4
|
-
export declare const GET_PRODUCT_OPTIONS_BY_HANDLE = "\n query GetProductOptionsByHandle(\n $handle: String!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productOptionsFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
5
|
-
export declare const GET_PRODUCT_OPTIONS_BY_ID_WITH_VARIANT = "\n query GetProductOptionsWithVariant(\n $productId: ID!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productOptionsFields\n }\n variant: node(id: $variantId) {\n ...productOptionsVariantFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
6
|
-
export declare const GET_PRODUCT_OPTIONS_BY_HANDLE_WITH_VARIANT = "\n query GetProductOptionsByHandleWithVariant(\n $handle: String!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productOptionsFields\n }\n variant: node(id: $variantId) {\n ...productOptionsVariantFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
7
|
-
export declare const GET_SELECTED_VARIANT = "\n query GetSelectedVariant(\n $productId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...selectedVariantFields\n }\n }\n \n fragment selectedVariantFields on Product {\n id\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
8
|
-
export declare const GET_SELECTED_VARIANT_BY_HANDLE = "\n query GetSelectedVariantByHandle(\n $handle: String!\n $selectedOptions: [SelectedOptionInput!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...selectedVariantFields\n }\n }\n \n fragment selectedVariantFields on Product {\n id\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
9
|
-
export declare const GET_PRODUCT_DETAIL_DATA_BY_ID = "\n query GetProductDetailData(\n $productId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n ...productOptionsFields\n ...productImagesFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
10
|
-
export declare const GET_PRODUCT_DETAIL_DATA_BY_ID_WITH_VARIANT = "\n query GetProductDetailDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n ...productOptionsFields\n ...productImagesFields\n }\n variant: node(id: $variantId) {\n ...productVariantDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productOptionsFields on Product {\n id\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
5
|
+
export declare const GET_PRODUCT_OPTIONS_BY_ID = "\n query GetProductOptions(\n $productId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productOptionsFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
6
|
+
export declare const GET_PRODUCT_OPTIONS_BY_HANDLE = "\n query GetProductOptionsByHandle(\n $handle: String!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productOptionsFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
7
|
+
export declare const GET_PRODUCT_OPTIONS_BY_ID_WITH_VARIANT = "\n query GetProductOptionsWithVariant(\n $productId: ID!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productOptionsFields\n }\n variant: node(id: $variantId) {\n ...productOptionsVariantFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
8
|
+
export declare const GET_PRODUCT_OPTIONS_BY_HANDLE_WITH_VARIANT = "\n query GetProductOptionsByHandleWithVariant(\n $handle: String!\n $variantId: ID!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...productOptionsFields\n }\n variant: node(id: $variantId) {\n ...productOptionsVariantFields\n }\n }\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productOptionsVariantFields on ProductVariant {\n id\n selectedOptions {\n name\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
9
|
+
export declare const GET_SELECTED_VARIANT = "\n query GetSelectedVariant(\n $productId: ID!\n $selectedOptions: [SelectedOptionInput!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...selectedVariantFields\n }\n }\n \n fragment selectedVariantFields on Product {\n id\n availableForSale\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
10
|
+
export declare const GET_SELECTED_VARIANT_BY_HANDLE = "\n query GetSelectedVariantByHandle(\n $handle: String!\n $selectedOptions: [SelectedOptionInput!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(handle: $handle) {\n ...selectedVariantFields\n }\n }\n \n fragment selectedVariantFields on Product {\n id\n availableForSale\n title\n handle\n featuredImage {\n ...productImageFields\n }\n variantBySelectedOptions(selectedOptions: $selectedOptions) {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n title\n selectedOptions {\n name\n value\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
11
|
+
export declare const GET_PRODUCT_DETAIL_DATA_BY_ID = "\n query GetProductDetailData(\n $productId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n ...productOptionsFields\n ...productImagesFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
12
|
+
export declare const GET_PRODUCT_DETAIL_DATA_BY_ID_WITH_VARIANT = "\n query GetProductDetailDataWithVariant(\n $productId: ID!\n $variantId: ID!\n $productMetafields: [HasMetafieldsIdentifier!]!\n $variantMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n product(id: $productId) {\n ...productCardDataFields\n ...productOptionsFields\n ...productImagesFields\n }\n variant: node(id: $variantId) {\n ...productVariantDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productOptionsFields on Product {\n id\n availableForSale\n title\n featuredImage {\n ...productImageFields\n }\n encodedVariantAvailability\n encodedVariantExistence\n variantsCount {\n count\n precision\n }\n options {\n id\n name\n optionValues {\n name\n swatch {\n color\n image {\n previewImage {\n url\n }\n }\n }\n firstSelectableVariant {\n id\n image {\n ...productImageFields\n }\n }\n }\n }\n }\n\n \n fragment productVariantDataFields on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n currentlyNotInStock\n image {\n ...productImageFields\n }\n price {\n amount\n currencyCode\n }\n # quantityAvailable\n selectedOptions {\n name\n value\n }\n sku\n title\n metafields(identifiers: $variantMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImagesFields on Product {\n images(first: 20) {\n nodes {\n ...productImageFields\n }\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
11
13
|
export declare const GET_PRODUCT_IMAGES_BY_ID = "\n query GetProductImagesById(\n $ids: [ID!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n nodes(ids: $ids) {\n ... on Product {\n featuredImage {\n ...productImageFields\n }\n }\n ... on ProductVariant {\n image {\n ...productImageFields\n }\n product {\n featuredImage {\n ...productImageFields\n }\n }\n }\n }\n }\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
12
14
|
export declare const GET_PRODUCT_RECOMMENDATIONS_BY_ID = "\n query GetProductRecommendationsById(\n $productId: ID!\n $intent: ProductRecommendationIntent\n $productMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n productRecommendations(productId: $productId, intent: $intent) {\n ...productCardDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
13
15
|
export declare const GET_PRODUCT_RECOMMENDATIONS_BY_HANDLE = "\n query GetProductRecommendationsByHandle(\n $handle: String!\n $intent: ProductRecommendationIntent\n $productMetafields: [HasMetafieldsIdentifier!]!\n $country: CountryCode!\n $language: LanguageCode!\n ) @inContext(country: $country, language: $language) {\n productRecommendations(productHandle: $handle, intent: $intent) {\n ...productCardDataFields\n }\n }\n \n fragment productCardDataFields on Product {\n id\n availableForSale\n category {\n id\n name\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n ...productImageFields\n }\n isGiftCard\n onlineStoreUrl\n description\n descriptionHtml\n handle\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n productType\n tags\n title\n variantsCount {\n count\n }\n # totalInventory\n metafields(identifiers: $productMetafields) {\n key\n namespace\n value\n }\n }\n\n \n fragment productImageFields on Image {\n id\n altText\n url\n thumbhash\n }\n\n";
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { ResponseErrors } from "@shopify/graphql-client";
|
|
2
2
|
import { LoadProductCardDataArgs } from "./load-product-card-data";
|
|
3
3
|
import { LoadProductDetailDataArgs } from "./load-product-detail-data";
|
|
4
|
+
import { LoadProductIdArgs } from "./load-product-id";
|
|
4
5
|
import { LoadProductImagesArgs } from "./load-product-images";
|
|
5
6
|
import { LoadProductOptionsArgs } from "./load-product-options";
|
|
6
|
-
import { LoadSelectedVariantArgs } from "./load-selected-variant";
|
|
7
7
|
import { LoadProductRecommendationsArgs } from "./load-product-recommendations";
|
|
8
|
-
import {
|
|
8
|
+
import { LoadSaveIntentDataArgs } from "./load-save-intent-data";
|
|
9
|
+
import { LoadSelectedVariantArgs } from "./load-selected-variant";
|
|
9
10
|
export * from "./load-product-card-data";
|
|
10
11
|
export * from "./load-product-options";
|
|
12
|
+
export * from "./load-product-recommendations";
|
|
11
13
|
export * from "./load-selected-variant";
|
|
12
14
|
export * from "./types/storefront.generated";
|
|
13
|
-
export * from "./load-product-recommendations";
|
|
14
15
|
export interface StorefrontApiResponse<TData> {
|
|
15
16
|
data: TData;
|
|
16
17
|
errors: ResponseErrors;
|
|
@@ -63,5 +64,9 @@ export declare class StorefrontApiClient {
|
|
|
63
64
|
data: import("./storefront-api-client").GetProductIdByHandleQuery | undefined;
|
|
64
65
|
errors: ResponseErrors | null;
|
|
65
66
|
}>;
|
|
67
|
+
loadSaveIntentData: (args: LoadSaveIntentDataArgs) => Promise<{
|
|
68
|
+
data: import("./storefront-api-client").GetSaveIntentDataQuery | import("./storefront-api-client").GetSaveIntentDataWithVariantQuery | undefined;
|
|
69
|
+
errors: ResponseErrors | null;
|
|
70
|
+
}>;
|
|
66
71
|
clearCache(): Promise<void>;
|
|
67
72
|
}
|