@swishapp/sdk 0.60.0 → 0.70.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/intents/handlers/open-quick-buy-handler.d.ts +1 -1
- package/dist/intents/intent-handler.d.ts +3 -1
- package/dist/intents/intent-hook.d.ts +6 -4
- package/dist/intents/intents.d.ts +15 -5
- package/dist/options/swish-options.d.ts +14 -0
- package/dist/options/types.d.ts +113 -0
- package/dist/state/index.d.ts +1 -0
- package/dist/storefront-api/load-product-card-data.d.ts +4 -2
- package/dist/storefront-api/load-product-detail-data.d.ts +4 -2
- package/dist/storefront-api/load-product-images.d.ts +4 -1
- package/dist/storefront-api/load-product-options.d.ts +4 -1
- package/dist/storefront-api/load-product-recommendations.d.ts +4 -2
- package/dist/storefront-api/load-save-intent-data.d.ts +8 -7
- package/dist/storefront-api/load-selected-variant.d.ts +4 -2
- package/dist/storefront-api/storefront-api-client.d.ts +120 -10
- package/dist/storefront-api/types/storefront.types.d.ts +107 -1
- package/dist/swish-api/swish-api-client.d.ts +4 -8
- package/dist/swish-ui/swish-ui-element.d.ts +3 -1
- package/dist/swish-ui/swish-ui.d.ts +54 -0
- package/dist/swish-ui/{swish-ui-utils.d.ts → types.d.ts} +4 -37
- package/dist/swish.d.ts +28 -20
- package/dist/swish.js +78 -78
- package/dist/types.d.ts +2 -45
- package/dist/utils/shop-bridge.d.ts +4 -2
- package/dist/utils/shopify-badge-utils.d.ts +22 -0
- package/package.json +9 -9
- package/dist/index.d.ts +0 -9
|
@@ -758,6 +758,16 @@ export declare enum CartCardSource {
|
|
|
758
758
|
*/
|
|
759
759
|
SavedCreditCard = "SAVED_CREDIT_CARD"
|
|
760
760
|
}
|
|
761
|
+
/** Return type for `cartClone` mutation. */
|
|
762
|
+
export type CartClonePayload = {
|
|
763
|
+
__typename?: 'CartClonePayload';
|
|
764
|
+
/** The newly created cart without PII. This is a different cart from the source. */
|
|
765
|
+
cart?: Maybe<Cart>;
|
|
766
|
+
/** The list of errors that occurred from executing the mutation. */
|
|
767
|
+
userErrors: Array<CartUserError>;
|
|
768
|
+
/** A list of warnings that occurred during the mutation. */
|
|
769
|
+
warnings: Array<CartWarning>;
|
|
770
|
+
};
|
|
761
771
|
/** The discount that has been applied to the cart line using a discount code. */
|
|
762
772
|
export type CartCodeDiscountAllocation = CartDiscountAllocation & {
|
|
763
773
|
__typename?: 'CartCodeDiscountAllocation';
|
|
@@ -1016,6 +1026,16 @@ export type CartDeliveryAddressesRemovePayload = {
|
|
|
1016
1026
|
/** A list of warnings that occurred during the mutation. */
|
|
1017
1027
|
warnings: Array<CartWarning>;
|
|
1018
1028
|
};
|
|
1029
|
+
/** Return type for `cartDeliveryAddressesReplace` mutation. */
|
|
1030
|
+
export type CartDeliveryAddressesReplacePayload = {
|
|
1031
|
+
__typename?: 'CartDeliveryAddressesReplacePayload';
|
|
1032
|
+
/** The updated cart. */
|
|
1033
|
+
cart?: Maybe<Cart>;
|
|
1034
|
+
/** The list of errors that occurred from executing the mutation. */
|
|
1035
|
+
userErrors: Array<CartUserError>;
|
|
1036
|
+
/** A list of warnings that occurred during the mutation. */
|
|
1037
|
+
warnings: Array<CartWarning>;
|
|
1038
|
+
};
|
|
1019
1039
|
/** Return type for `cartDeliveryAddressesUpdate` mutation. */
|
|
1020
1040
|
export type CartDeliveryAddressesUpdatePayload = {
|
|
1021
1041
|
__typename?: 'CartDeliveryAddressesUpdatePayload';
|
|
@@ -1248,6 +1268,10 @@ export declare enum CartErrorCode {
|
|
|
1248
1268
|
AddressFieldIsRequired = "ADDRESS_FIELD_IS_REQUIRED",
|
|
1249
1269
|
/** The specified address field is too long. */
|
|
1250
1270
|
AddressFieldIsTooLong = "ADDRESS_FIELD_IS_TOO_LONG",
|
|
1271
|
+
/** Bundles and addons cannot be mixed. */
|
|
1272
|
+
BundlesAndAddonsCannotBeMixed = "BUNDLES_AND_ADDONS_CANNOT_BE_MIXED",
|
|
1273
|
+
/** Buyer cannot purchase for company location. */
|
|
1274
|
+
BuyerCannotPurchaseForCompanyLocation = "BUYER_CANNOT_PURCHASE_FOR_COMPANY_LOCATION",
|
|
1251
1275
|
/** The cart is too large to save. */
|
|
1252
1276
|
CartTooLarge = "CART_TOO_LARGE",
|
|
1253
1277
|
/** The input value is invalid. */
|
|
@@ -1280,6 +1304,8 @@ export declare enum CartErrorCode {
|
|
|
1280
1304
|
LessThan = "LESS_THAN",
|
|
1281
1305
|
/** The quantity must be below the specified maximum for the item. */
|
|
1282
1306
|
MaximumExceeded = "MAXIMUM_EXCEEDED",
|
|
1307
|
+
/** Item cannot be purchased as configured. */
|
|
1308
|
+
MerchandiseNotApplicable = "MERCHANDISE_NOT_APPLICABLE",
|
|
1283
1309
|
/** The quantity must be above the specified minimum for the item. */
|
|
1284
1310
|
MinimumNotMet = "MINIMUM_NOT_MET",
|
|
1285
1311
|
/** The customer access token is required when setting a company location. */
|
|
@@ -1292,6 +1318,12 @@ export declare enum CartErrorCode {
|
|
|
1292
1318
|
NoteTooLong = "NOTE_TOO_LONG",
|
|
1293
1319
|
/** Only one delivery address can be selected. */
|
|
1294
1320
|
OnlyOneDeliveryAddressCanBeSelected = "ONLY_ONE_DELIVERY_ADDRESS_CAN_BE_SELECTED",
|
|
1321
|
+
/** Parent line nesting is too deep or circular. */
|
|
1322
|
+
ParentLineNestingTooDeep = "PARENT_LINE_NESTING_TOO_DEEP",
|
|
1323
|
+
/** Parent line not found. */
|
|
1324
|
+
ParentLineNotFound = "PARENT_LINE_NOT_FOUND",
|
|
1325
|
+
/** Nested cartlines are blocked due to an incompatibility. */
|
|
1326
|
+
ParentLineOperationBlocked = "PARENT_LINE_OPERATION_BLOCKED",
|
|
1295
1327
|
/** Credit card has expired. */
|
|
1296
1328
|
PaymentsCreditCardBaseExpired = "PAYMENTS_CREDIT_CARD_BASE_EXPIRED",
|
|
1297
1329
|
/** Credit card gateway is not supported. */
|
|
@@ -1357,6 +1389,16 @@ export type CartFreePaymentMethodInput = {
|
|
|
1357
1389
|
/** The customer's billing address. */
|
|
1358
1390
|
billingAddress: MailingAddressInput;
|
|
1359
1391
|
};
|
|
1392
|
+
/** Return type for `cartGiftCardCodesAdd` mutation. */
|
|
1393
|
+
export type CartGiftCardCodesAddPayload = {
|
|
1394
|
+
__typename?: 'CartGiftCardCodesAddPayload';
|
|
1395
|
+
/** The updated cart. */
|
|
1396
|
+
cart?: Maybe<Cart>;
|
|
1397
|
+
/** The list of errors that occurred from executing the mutation. */
|
|
1398
|
+
userErrors: Array<CartUserError>;
|
|
1399
|
+
/** A list of warnings that occurred during the mutation. */
|
|
1400
|
+
warnings: Array<CartWarning>;
|
|
1401
|
+
};
|
|
1360
1402
|
/** Return type for `cartGiftCardCodesRemove` mutation. */
|
|
1361
1403
|
export type CartGiftCardCodesRemovePayload = {
|
|
1362
1404
|
__typename?: 'CartGiftCardCodesRemovePayload';
|
|
@@ -1458,8 +1500,12 @@ export type CartLine = BaseCartLine & Node & {
|
|
|
1458
1500
|
estimatedCost: CartLineEstimatedCost;
|
|
1459
1501
|
/** A globally-unique ID. */
|
|
1460
1502
|
id: Scalars['ID']['output'];
|
|
1503
|
+
/** The instructions for the line item. */
|
|
1504
|
+
instructions: CartLineInstructions;
|
|
1461
1505
|
/** The merchandise that the buyer intends to purchase. */
|
|
1462
1506
|
merchandise: Merchandise;
|
|
1507
|
+
/** The parent of the line item. */
|
|
1508
|
+
parentRelationship?: Maybe<CartLineParentRelationship>;
|
|
1463
1509
|
/** The quantity of the merchandise that the customer intends to purchase. */
|
|
1464
1510
|
quantity: Scalars['Int']['output'];
|
|
1465
1511
|
/** The selling plan associated with the cart line and the effect that each selling plan has on variants when they're purchased. */
|
|
@@ -1506,11 +1552,34 @@ export type CartLineInput = {
|
|
|
1506
1552
|
attributes?: InputMaybe<Array<AttributeInput>>;
|
|
1507
1553
|
/** The ID of the merchandise that the buyer intends to purchase. */
|
|
1508
1554
|
merchandiseId: Scalars['ID']['input'];
|
|
1555
|
+
/** The parent line item of the cart line. */
|
|
1556
|
+
parent?: InputMaybe<CartLineParentInput>;
|
|
1509
1557
|
/** The quantity of the merchandise. */
|
|
1510
1558
|
quantity?: InputMaybe<Scalars['Int']['input']>;
|
|
1511
1559
|
/** The ID of the selling plan that the merchandise is being purchased with. */
|
|
1512
1560
|
sellingPlanId?: InputMaybe<Scalars['ID']['input']>;
|
|
1513
1561
|
};
|
|
1562
|
+
/** Represents instructions for a cart line item. */
|
|
1563
|
+
export type CartLineInstructions = {
|
|
1564
|
+
__typename?: 'CartLineInstructions';
|
|
1565
|
+
/** Whether the line item can be removed from the cart. */
|
|
1566
|
+
canRemove: Scalars['Boolean']['output'];
|
|
1567
|
+
/** Whether the line item quantity can be updated. */
|
|
1568
|
+
canUpdateQuantity: Scalars['Boolean']['output'];
|
|
1569
|
+
};
|
|
1570
|
+
/** The parent line item of the cart line. */
|
|
1571
|
+
export type CartLineParentInput = {
|
|
1572
|
+
/** The id of the parent line item. */
|
|
1573
|
+
lineId?: InputMaybe<Scalars['ID']['input']>;
|
|
1574
|
+
/** The ID of the parent line merchandise. */
|
|
1575
|
+
merchandiseId?: InputMaybe<Scalars['ID']['input']>;
|
|
1576
|
+
};
|
|
1577
|
+
/** Represents the parent relationship of a cart line. */
|
|
1578
|
+
export type CartLineParentRelationship = {
|
|
1579
|
+
__typename?: 'CartLineParentRelationship';
|
|
1580
|
+
/** The parent cart line. */
|
|
1581
|
+
parent: CartLine;
|
|
1582
|
+
};
|
|
1514
1583
|
/** The input fields to update a line item on a cart. */
|
|
1515
1584
|
export type CartLineUpdateInput = {
|
|
1516
1585
|
/**
|
|
@@ -1866,6 +1935,8 @@ export declare enum CartWarningCode {
|
|
|
1866
1935
|
MerchandiseNotEnoughStock = "MERCHANDISE_NOT_ENOUGH_STOCK",
|
|
1867
1936
|
/** The merchandise is out of stock. */
|
|
1868
1937
|
MerchandiseOutOfStock = "MERCHANDISE_OUT_OF_STOCK",
|
|
1938
|
+
/** Only one-time purchase is available for B2B orders. */
|
|
1939
|
+
MerchandiseSellingPlanNotApplicableOnCompanyLocation = "MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION",
|
|
1869
1940
|
/** Gift cards are not available as a payment method. */
|
|
1870
1941
|
PaymentsGiftCardsUnavailable = "PAYMENTS_GIFT_CARDS_UNAVAILABLE"
|
|
1871
1942
|
}
|
|
@@ -4782,6 +4853,8 @@ export type MetafieldReferencesArgs = {
|
|
|
4782
4853
|
};
|
|
4783
4854
|
/** Possible error codes that can be returned by `MetafieldDeleteUserError`. */
|
|
4784
4855
|
export declare enum MetafieldDeleteErrorCode {
|
|
4856
|
+
/** The current app is not authorized to perform this action. */
|
|
4857
|
+
AppNotAuthorized = "APP_NOT_AUTHORIZED",
|
|
4785
4858
|
/** The owner ID is invalid. */
|
|
4786
4859
|
InvalidOwner = "INVALID_OWNER",
|
|
4787
4860
|
/** Metafield not found. */
|
|
@@ -4821,7 +4894,7 @@ export type MetafieldParentResource = Article | Blog | Cart | Collection | Compa
|
|
|
4821
4894
|
* Returns the resource which is being referred to by a metafield.
|
|
4822
4895
|
*
|
|
4823
4896
|
*/
|
|
4824
|
-
export type MetafieldReference = Collection | GenericFile | MediaImage | Metaobject | Model3d | Page | Product | ProductVariant | Video;
|
|
4897
|
+
export type MetafieldReference = Article | Collection | GenericFile | MediaImage | Metaobject | Model3d | Page | Product | ProductVariant | Video;
|
|
4825
4898
|
/**
|
|
4826
4899
|
* An auto-generated type for paginating through multiple MetafieldReferences.
|
|
4827
4900
|
*
|
|
@@ -4860,6 +4933,8 @@ export type MetafieldsSetUserError = DisplayableError & {
|
|
|
4860
4933
|
};
|
|
4861
4934
|
/** Possible error codes that can be returned by `MetafieldsSetUserError`. */
|
|
4862
4935
|
export declare enum MetafieldsSetUserErrorCode {
|
|
4936
|
+
/** The current app is not authorized to perform this action. */
|
|
4937
|
+
AppNotAuthorized = "APP_NOT_AUTHORIZED",
|
|
4863
4938
|
/** The input value is blank. */
|
|
4864
4939
|
Blank = "BLANK",
|
|
4865
4940
|
/** The input value isn't included in the list. */
|
|
@@ -5036,16 +5111,22 @@ export type Mutation = {
|
|
|
5036
5111
|
*
|
|
5037
5112
|
*/
|
|
5038
5113
|
cartBuyerIdentityUpdate?: Maybe<CartBuyerIdentityUpdatePayload>;
|
|
5114
|
+
/** Creates a clone of the specified cart with all personally identifiable information removed. */
|
|
5115
|
+
cartClone?: Maybe<CartClonePayload>;
|
|
5039
5116
|
/** Creates a new cart. */
|
|
5040
5117
|
cartCreate?: Maybe<CartCreatePayload>;
|
|
5041
5118
|
/** Adds delivery addresses to the cart. */
|
|
5042
5119
|
cartDeliveryAddressesAdd?: Maybe<CartDeliveryAddressesAddPayload>;
|
|
5043
5120
|
/** Removes delivery addresses from the cart. */
|
|
5044
5121
|
cartDeliveryAddressesRemove?: Maybe<CartDeliveryAddressesRemovePayload>;
|
|
5122
|
+
/** Replaces delivery addresses on the cart. */
|
|
5123
|
+
cartDeliveryAddressesReplace?: Maybe<CartDeliveryAddressesReplacePayload>;
|
|
5045
5124
|
/** Updates one or more delivery addresses on a cart. */
|
|
5046
5125
|
cartDeliveryAddressesUpdate?: Maybe<CartDeliveryAddressesUpdatePayload>;
|
|
5047
5126
|
/** Updates the discount codes applied to the cart. */
|
|
5048
5127
|
cartDiscountCodesUpdate?: Maybe<CartDiscountCodesUpdatePayload>;
|
|
5128
|
+
/** Adds gift card codes to the cart without replacing existing ones. */
|
|
5129
|
+
cartGiftCardCodesAdd?: Maybe<CartGiftCardCodesAddPayload>;
|
|
5049
5130
|
/** Removes the gift card codes applied to the cart. */
|
|
5050
5131
|
cartGiftCardCodesRemove?: Maybe<CartGiftCardCodesRemovePayload>;
|
|
5051
5132
|
/** Updates the gift card codes applied to the cart. */
|
|
@@ -5164,6 +5245,10 @@ export type MutationCartBuyerIdentityUpdateArgs = {
|
|
|
5164
5245
|
cartId: Scalars['ID']['input'];
|
|
5165
5246
|
};
|
|
5166
5247
|
/** The schema’s entry-point for mutations. This acts as the public, top-level API from which all mutation queries must start. */
|
|
5248
|
+
export type MutationCartCloneArgs = {
|
|
5249
|
+
cartId: Scalars['ID']['input'];
|
|
5250
|
+
};
|
|
5251
|
+
/** The schema’s entry-point for mutations. This acts as the public, top-level API from which all mutation queries must start. */
|
|
5167
5252
|
export type MutationCartCreateArgs = {
|
|
5168
5253
|
input?: InputMaybe<CartInput>;
|
|
5169
5254
|
};
|
|
@@ -5178,6 +5263,11 @@ export type MutationCartDeliveryAddressesRemoveArgs = {
|
|
|
5178
5263
|
cartId: Scalars['ID']['input'];
|
|
5179
5264
|
};
|
|
5180
5265
|
/** The schema’s entry-point for mutations. This acts as the public, top-level API from which all mutation queries must start. */
|
|
5266
|
+
export type MutationCartDeliveryAddressesReplaceArgs = {
|
|
5267
|
+
addresses: Array<CartSelectableAddressInput>;
|
|
5268
|
+
cartId: Scalars['ID']['input'];
|
|
5269
|
+
};
|
|
5270
|
+
/** The schema’s entry-point for mutations. This acts as the public, top-level API from which all mutation queries must start. */
|
|
5181
5271
|
export type MutationCartDeliveryAddressesUpdateArgs = {
|
|
5182
5272
|
addresses: Array<CartSelectableAddressUpdateInput>;
|
|
5183
5273
|
cartId: Scalars['ID']['input'];
|
|
@@ -5188,6 +5278,11 @@ export type MutationCartDiscountCodesUpdateArgs = {
|
|
|
5188
5278
|
discountCodes?: InputMaybe<Array<Scalars['String']['input']>>;
|
|
5189
5279
|
};
|
|
5190
5280
|
/** The schema’s entry-point for mutations. This acts as the public, top-level API from which all mutation queries must start. */
|
|
5281
|
+
export type MutationCartGiftCardCodesAddArgs = {
|
|
5282
|
+
cartId: Scalars['ID']['input'];
|
|
5283
|
+
giftCardCodes: Array<Scalars['String']['input']>;
|
|
5284
|
+
};
|
|
5285
|
+
/** The schema’s entry-point for mutations. This acts as the public, top-level API from which all mutation queries must start. */
|
|
5191
5286
|
export type MutationCartGiftCardCodesRemoveArgs = {
|
|
5192
5287
|
appliedGiftCardIds: Array<Scalars['ID']['input']>;
|
|
5193
5288
|
cartId: Scalars['ID']['input'];
|
|
@@ -8447,6 +8542,17 @@ export type VideoSource = {
|
|
|
8447
8542
|
/** The width of the video. */
|
|
8448
8543
|
width: Scalars['Int']['output'];
|
|
8449
8544
|
};
|
|
8545
|
+
/** The visitor's consent to data processing purposes for the shop. true means accepting the purposes, false means declining them, and null means that the visitor didn't express a preference. */
|
|
8546
|
+
export type VisitorConsent = {
|
|
8547
|
+
/** The visitor accepts or rejects the analytics data processing purpose. */
|
|
8548
|
+
analytics?: InputMaybe<Scalars['Boolean']['input']>;
|
|
8549
|
+
/** The visitor accepts or rejects the first and third party marketing data processing purposes. */
|
|
8550
|
+
marketing?: InputMaybe<Scalars['Boolean']['input']>;
|
|
8551
|
+
/** The visitor accepts or rejects the preferences data processing purpose. */
|
|
8552
|
+
preferences?: InputMaybe<Scalars['Boolean']['input']>;
|
|
8553
|
+
/** The visitor accepts or rejects the sale or sharing of their data with third parties. */
|
|
8554
|
+
saleOfData?: InputMaybe<Scalars['Boolean']['input']>;
|
|
8555
|
+
};
|
|
8450
8556
|
/** Units of measurement for weight. */
|
|
8451
8557
|
export declare enum WeightUnit {
|
|
8452
8558
|
/** Metric system unit of mass. */
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import { ApiResponse, Item, ItemControllerFindData, ItemDetail, ListControllerFindData, ListDetail,
|
|
1
|
+
import { ApiResponse, Item, ItemControllerFindData, ItemDetail, ListControllerFindData, ListDetail, OrderDetailDto, OrderDto, OrdersControllerFindData, PaginatedApiResponse, SwishClientConfig } from "@swishapp/api-client";
|
|
2
|
+
import { StorefrontContext } from "../options/types";
|
|
2
3
|
export interface SwishApiConfig extends SwishClientConfig {
|
|
3
4
|
proxyMode?: boolean;
|
|
4
5
|
customerId?: string;
|
|
5
|
-
loadProfile?: () => string | undefined;
|
|
6
|
-
storeProfile?: (profile: string) => void;
|
|
7
|
-
deleteProfile?: () => void;
|
|
8
|
-
loadAuthToken?: () => string | undefined;
|
|
9
|
-
storeAuthToken?: (token: string) => void;
|
|
10
|
-
deleteAuthToken?: () => void;
|
|
11
6
|
responseInterceptor?: (response: Response, request: Request) => Promise<void> | void;
|
|
12
7
|
}
|
|
13
8
|
export declare class SwishApi {
|
|
14
9
|
private readonly cache;
|
|
15
10
|
private readonly apiClient;
|
|
16
11
|
private readonly config;
|
|
12
|
+
private readonly context;
|
|
17
13
|
private readonly itemsLoader;
|
|
18
|
-
constructor(config: SwishApiConfig, cacheKeyPrefix: string);
|
|
14
|
+
constructor(config: SwishApiConfig, context: StorefrontContext, cacheKeyPrefix: string);
|
|
19
15
|
private _bootstrapAuthPromise?;
|
|
20
16
|
bootstrapAuth(): Promise<void>;
|
|
21
17
|
private processProfileHeader;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export interface Ref<T> {
|
|
2
2
|
current: T;
|
|
3
3
|
}
|
|
4
|
-
|
|
4
|
+
declare const BaseElement: typeof HTMLElement;
|
|
5
|
+
export declare class SwishUiElement extends BaseElement {
|
|
5
6
|
constructor();
|
|
6
7
|
private componentRef;
|
|
7
8
|
getComponentRef: <TComponent = unknown>() => Ref<TComponent>;
|
|
8
9
|
setComponentRef: <TComponent = unknown>(ref: Ref<TComponent>) => void;
|
|
9
10
|
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ShopBridge } from "../utils/shop-bridge";
|
|
2
|
+
import type { SwishUiElement } from "./swish-ui-element";
|
|
3
|
+
import "../utils/shop-bridge";
|
|
4
|
+
import { StorefrontContext, SwishUiOptions } from "../options/types";
|
|
5
|
+
import { DeleteListAlertOptions, DrawerOptions, ListMenuOptions, ListSelectOptions, ListDetailPageOptions, SignInOptions, Toast, UnsaveAlertOptions, VariantSelectOptions, QuickBuyOptions, ListEditorOptions, RequireUiComponentOptions } from "./types";
|
|
6
|
+
export declare class SwishUi {
|
|
7
|
+
private storefrontContext;
|
|
8
|
+
private swishUiOptions;
|
|
9
|
+
private inflightModals;
|
|
10
|
+
private eventListeners;
|
|
11
|
+
private scrollLockStyleSheet;
|
|
12
|
+
private scrollLockRefCount;
|
|
13
|
+
private scrollPositionBeforeLock;
|
|
14
|
+
constructor(swishUiOptions: SwishUiOptions, storefrontContext: StorefrontContext);
|
|
15
|
+
hideModal(element: string | HTMLElement): Promise<void>;
|
|
16
|
+
showModal(element: string | HTMLElement): Promise<void>;
|
|
17
|
+
showSignIn(options?: SignInOptions): Promise<void>;
|
|
18
|
+
showUnsaveAlert(options: UnsaveAlertOptions): Promise<void>;
|
|
19
|
+
showDeleteListAlert(options: DeleteListAlertOptions): Promise<void>;
|
|
20
|
+
showDrawer(options?: DrawerOptions): Promise<void>;
|
|
21
|
+
showListMenu(options: ListMenuOptions): Promise<void>;
|
|
22
|
+
showListSelect(options: ListSelectOptions): Promise<void>;
|
|
23
|
+
initListDetailPage(options: ListDetailPageOptions, refElement: HTMLElement): Promise<void>;
|
|
24
|
+
showToast(toast: Toast): Promise<void>;
|
|
25
|
+
hideAllToasts(): Promise<void>;
|
|
26
|
+
showVariantSelect(options?: VariantSelectOptions): Promise<void>;
|
|
27
|
+
showQuickBuy(options?: QuickBuyOptions): Promise<void>;
|
|
28
|
+
showListEditor(options?: ListEditorOptions): Promise<void>;
|
|
29
|
+
initShopBridge({ onShopModalOpen }: {
|
|
30
|
+
onShopModalOpen: () => void;
|
|
31
|
+
}): Promise<ShopBridge>;
|
|
32
|
+
requireUiComponent<TComponent = unknown>(name: string, options?: RequireUiComponentOptions<TComponent>): Promise<SwishUiElement>;
|
|
33
|
+
private _loadCricalResourcesPromise;
|
|
34
|
+
loadCricalResources(): Promise<{
|
|
35
|
+
themeVariablesStylesheet: CSSStyleSheet;
|
|
36
|
+
}>;
|
|
37
|
+
private _loadNonCriticalResourcesPromise;
|
|
38
|
+
loadNonCriticalResources(): Promise<{
|
|
39
|
+
bundleCssStylesheet: CSSStyleSheet;
|
|
40
|
+
customCssStylesheets: CSSStyleSheet[];
|
|
41
|
+
}>;
|
|
42
|
+
insertComponent<T extends HTMLElement = SwishUiElement>({ name, instance, template, position, refElement, }: {
|
|
43
|
+
name: string;
|
|
44
|
+
instance?: string;
|
|
45
|
+
template: string;
|
|
46
|
+
position: InsertPosition;
|
|
47
|
+
refElement: HTMLElement;
|
|
48
|
+
}): Promise<T>;
|
|
49
|
+
queryComponent<T extends HTMLElement = SwishUiElement>(name: string, instance?: string): T;
|
|
50
|
+
private lockScroll;
|
|
51
|
+
private unlockScroll;
|
|
52
|
+
_lockScroll: () => void;
|
|
53
|
+
_unlockScroll: () => void;
|
|
54
|
+
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ShopBridge } from "../utils/shop-bridge";
|
|
3
|
-
import type { Ref, SwishUiElement } from "./swish-ui-element";
|
|
4
|
-
import { Item, ItemDetail, List } from "@swishapp/api-client";
|
|
5
|
-
import { GetProductCardDataWithVariantQuery, GetSelectedVariantQuery } from "../storefront-api/storefront-api-client";
|
|
6
|
-
import "../utils/shop-bridge";
|
|
1
|
+
import { GetProductCardDataWithVariantQuery, GetSelectedVariantQuery, Item, ItemDetail, List, Ref } from "../swish";
|
|
7
2
|
export interface ToastManager {
|
|
8
3
|
show(toast: Toast): string;
|
|
9
4
|
hide(id: string): void;
|
|
@@ -19,14 +14,10 @@ export interface Toast {
|
|
|
19
14
|
onClick?: () => void;
|
|
20
15
|
};
|
|
21
16
|
}
|
|
22
|
-
export declare const setConfig: (opts: SwishUiOptions) => void;
|
|
23
|
-
export declare const hideModal: (element: string | HTMLElement) => Promise<void>;
|
|
24
|
-
export declare const showModal: (element: string | HTMLElement) => Promise<void>;
|
|
25
17
|
export interface SignInOptions {
|
|
26
18
|
returnTo?: string;
|
|
27
19
|
onClose?: () => void;
|
|
28
20
|
}
|
|
29
|
-
export declare const showSignIn: (options?: SignInOptions) => Promise<void>;
|
|
30
21
|
export interface UnsaveAlertOptions {
|
|
31
22
|
itemId: string;
|
|
32
23
|
onSubmit?: (data: UnsaveAlertSubmitData) => void;
|
|
@@ -35,24 +26,23 @@ export interface UnsaveAlertOptions {
|
|
|
35
26
|
export interface UnsaveAlertSubmitData {
|
|
36
27
|
itemId: string;
|
|
37
28
|
}
|
|
38
|
-
export declare const showUnsaveAlert: (options: UnsaveAlertOptions) => Promise<void>;
|
|
39
29
|
export interface DeleteListAlertOptions {
|
|
40
30
|
listId: string;
|
|
41
31
|
onSubmit?: () => void;
|
|
42
32
|
onClose?: () => void;
|
|
43
33
|
}
|
|
44
|
-
export declare const showDeleteListAlert: (options: DeleteListAlertOptions) => Promise<void>;
|
|
45
34
|
export interface DrawerOptions {
|
|
46
35
|
onClose?: () => void;
|
|
47
36
|
}
|
|
48
|
-
export declare const showDrawer: (options?: DrawerOptions) => Promise<void>;
|
|
49
37
|
export interface ListMenuOptions {
|
|
50
38
|
listId: string;
|
|
51
39
|
onClose?: () => void;
|
|
52
40
|
onEdit?: (data: ListEditorSubmitData) => void;
|
|
53
41
|
onDelete?: () => void;
|
|
54
42
|
}
|
|
55
|
-
export
|
|
43
|
+
export interface ListDetailPageOptions {
|
|
44
|
+
listId?: string;
|
|
45
|
+
}
|
|
56
46
|
export interface ListSelectOptions {
|
|
57
47
|
itemId: string;
|
|
58
48
|
onSubmit?: (data: ListSelectSubmitData) => void | Promise<void>;
|
|
@@ -66,13 +56,6 @@ export interface ListSelectSubmitData {
|
|
|
66
56
|
product: ListSelectProduct;
|
|
67
57
|
variant?: ListSelectVariant;
|
|
68
58
|
}
|
|
69
|
-
export declare const showListSelect: (options: ListSelectOptions) => Promise<void>;
|
|
70
|
-
export interface ListDetailPageOptions {
|
|
71
|
-
listId?: string;
|
|
72
|
-
}
|
|
73
|
-
export declare const initListDetailPage: (options: ListDetailPageOptions, refElement: HTMLElement) => Promise<void>;
|
|
74
|
-
export declare const showToast: (toast: Toast) => Promise<void>;
|
|
75
|
-
export declare const hideAllToasts: () => Promise<void>;
|
|
76
59
|
export interface VariantSelectOptions {
|
|
77
60
|
productId?: string;
|
|
78
61
|
productHandle?: string;
|
|
@@ -88,7 +71,6 @@ export interface VariantSelectSubmitData {
|
|
|
88
71
|
product: VariantSelectProduct;
|
|
89
72
|
variant: VariantSelectVariant;
|
|
90
73
|
}
|
|
91
|
-
export declare const showVariantSelect: (options?: VariantSelectOptions) => Promise<void>;
|
|
92
74
|
export interface QuickBuyOptions {
|
|
93
75
|
productId?: string;
|
|
94
76
|
variantId?: string;
|
|
@@ -101,7 +83,6 @@ export interface QuickBuySubmitData {
|
|
|
101
83
|
product: QuickBuyProduct;
|
|
102
84
|
variant: QuickBuyVariant;
|
|
103
85
|
}
|
|
104
|
-
export declare const showQuickBuy: (options?: QuickBuyOptions) => Promise<void>;
|
|
105
86
|
export interface ListEditorOptions {
|
|
106
87
|
listId?: string;
|
|
107
88
|
onSubmit: (data: ListEditorSubmitData) => void | Promise<void>;
|
|
@@ -110,23 +91,9 @@ export interface ListEditorOptions {
|
|
|
110
91
|
export interface ListEditorSubmitData {
|
|
111
92
|
list: List;
|
|
112
93
|
}
|
|
113
|
-
export declare const showListEditor: (options?: ListEditorOptions) => Promise<void>;
|
|
114
|
-
export declare const initShopBridge: ({ onShopModalOpen, }: {
|
|
115
|
-
onShopModalOpen: () => void;
|
|
116
|
-
}) => Promise<ShopBridge>;
|
|
117
|
-
export declare const loadManifest: () => Promise<SwishUiManifest>;
|
|
118
94
|
export interface RequireUiComponentOptions<TComponent> {
|
|
119
95
|
instance?: string;
|
|
120
96
|
listeners?: Record<string, (event: Event | CustomEvent) => void>;
|
|
121
97
|
onHydrated?: (ref: Ref<TComponent>) => void;
|
|
122
98
|
refElement?: HTMLElement;
|
|
123
99
|
}
|
|
124
|
-
export declare const requireUiComponent: <TComponent = unknown>(name: string, options?: RequireUiComponentOptions<TComponent>) => Promise<SwishUiElement>;
|
|
125
|
-
export declare const insertComponent: <T extends HTMLElement = SwishUiElement>({ name, instance, template, position, refElement, }: {
|
|
126
|
-
name: string;
|
|
127
|
-
instance?: string;
|
|
128
|
-
template: string;
|
|
129
|
-
position: InsertPosition;
|
|
130
|
-
refElement: HTMLElement;
|
|
131
|
-
}) => Promise<T>;
|
|
132
|
-
export declare const queryComponent: <T extends HTMLElement = SwishUiElement>(name: string, instance?: string) => T;
|
package/dist/swish.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SwishAppOptions, SwishEmbedData } from "./types";
|
|
2
1
|
import { AjaxApiClient } from "./ajax-api/ajax-api-client";
|
|
3
2
|
import { createElementLocator, createLocationObserver } from "./dom/dom-utils";
|
|
4
3
|
import { EventBus } from "./events/event-bus";
|
|
@@ -6,19 +5,25 @@ import { Intents } from "./intents/intents";
|
|
|
6
5
|
import { computed, effect, signal } from "./state";
|
|
7
6
|
import { StorefrontApiClient } from "./storefront-api/storefront-api-client";
|
|
8
7
|
import { SwishApi } from "./swish-api/swish-api-client";
|
|
8
|
+
import { ShopifyBadgesUtils } from "./utils/shopify-badge-utils";
|
|
9
|
+
import { SwishOptionsInput } from "./options/swish-options";
|
|
10
|
+
import { SwishOptions } from "./options/types";
|
|
11
|
+
import { SwishUi } from "./swish-ui/swish-ui";
|
|
9
12
|
export declare const VERSION: string;
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const swishApp: (options: SwishAppOptions) => Promise<SwishApp>;
|
|
13
|
+
export declare const createSwish: (optionsInput: SwishOptionsInput) => Promise<SwishApp>;
|
|
12
14
|
export declare class SwishApp {
|
|
13
15
|
private readonly swishApi;
|
|
14
16
|
private readonly swishApiPublisher;
|
|
15
17
|
private readonly storefrontApi;
|
|
16
18
|
private readonly ajaxApi;
|
|
17
19
|
private readonly ajaxApiPublisher;
|
|
18
|
-
private readonly
|
|
20
|
+
private readonly swishBadges;
|
|
21
|
+
private readonly swishOptions;
|
|
22
|
+
private readonly swishUi;
|
|
19
23
|
readonly events: EventBus;
|
|
20
24
|
readonly intents: Intents;
|
|
21
|
-
constructor(options:
|
|
25
|
+
constructor(options: SwishOptions);
|
|
26
|
+
get options(): SwishOptions;
|
|
22
27
|
get customer(): {
|
|
23
28
|
id: string | null;
|
|
24
29
|
email: string | null;
|
|
@@ -27,28 +32,21 @@ export declare class SwishApp {
|
|
|
27
32
|
b2b: boolean | null;
|
|
28
33
|
};
|
|
29
34
|
get localization(): {
|
|
30
|
-
country:
|
|
31
|
-
language:
|
|
32
|
-
market:
|
|
35
|
+
country: import("./storefront-api/types/storefront.types").CountryCode;
|
|
36
|
+
language: import("./storefront-api/types/storefront.types").LanguageCode;
|
|
37
|
+
market: string;
|
|
33
38
|
};
|
|
34
|
-
get
|
|
39
|
+
get routes(): {
|
|
35
40
|
accountUrl: string;
|
|
36
41
|
accountLoginUrl: string;
|
|
37
42
|
rootUrl: string;
|
|
38
43
|
};
|
|
44
|
+
get badges(): ShopifyBadgesUtils;
|
|
39
45
|
get api(): SwishApi;
|
|
40
46
|
get storefront(): StorefrontApiClient;
|
|
41
47
|
get ajax(): AjaxApiClient;
|
|
42
48
|
get shopUrl(): string;
|
|
43
|
-
|
|
44
|
-
hideModal: (element: string | HTMLElement) => Promise<void>;
|
|
45
|
-
showModal: (element: string | HTMLElement) => Promise<void>;
|
|
46
|
-
initShopBridge: ({ onShopModalOpen, }: {
|
|
47
|
-
onShopModalOpen: () => void;
|
|
48
|
-
}) => Promise<import(".").ShopBridge>;
|
|
49
|
-
showToast: (toast: import(".").Toast) => Promise<void>;
|
|
50
|
-
initListDetailPage: (options: import("./swish-ui/swish-ui-utils").ListDetailPageOptions, refElement: HTMLElement) => Promise<void>;
|
|
51
|
-
};
|
|
49
|
+
get ui(): SwishUi;
|
|
52
50
|
readonly dom: {
|
|
53
51
|
createElementLocator: typeof createElementLocator;
|
|
54
52
|
createQueryParamsObserver: typeof createLocationObserver;
|
|
@@ -75,10 +73,10 @@ export declare class SwishApp {
|
|
|
75
73
|
loading: boolean;
|
|
76
74
|
error: import("@swishapp/api-client").ApiError | null;
|
|
77
75
|
}>;
|
|
78
|
-
swishQuery: <TResponse extends import("@swishapp/api-client").ApiResponse<any> | import("@swishapp/api-client").PaginatedApiResponse<any>, TVariables>(fetch: import("./state
|
|
76
|
+
swishQuery: <TResponse extends import("@swishapp/api-client").ApiResponse<any> | import("@swishapp/api-client").PaginatedApiResponse<any>, TVariables>(fetch: import("./state").FetchFn<TResponse, TVariables>, options?: {
|
|
79
77
|
variables?: import("@preact/signals-core").Signal<TVariables>;
|
|
80
78
|
skip?: import("@preact/signals-core").Signal<boolean>;
|
|
81
|
-
refetch?: import("
|
|
79
|
+
refetch?: import("./swish").EventName[];
|
|
82
80
|
}) => {
|
|
83
81
|
data: import("@preact/signals-core").Signal<(TResponse extends {
|
|
84
82
|
data: infer D;
|
|
@@ -93,3 +91,13 @@ export declare class SwishApp {
|
|
|
93
91
|
computed: typeof computed;
|
|
94
92
|
};
|
|
95
93
|
}
|
|
94
|
+
export type * from "./types";
|
|
95
|
+
export type * from "@swishapp/api-client";
|
|
96
|
+
export type * from "./ajax-api/ajax-api-client";
|
|
97
|
+
export type { EventName } from "./events/event-bus";
|
|
98
|
+
export type * from "./storefront-api/storefront-api-client";
|
|
99
|
+
export type * from "./intents/types";
|
|
100
|
+
export type { Ref, SwishUiElement } from "./swish-ui/swish-ui-element";
|
|
101
|
+
export type { Toast, ToastManager, UnsaveAlertSubmitData, ListSelectSubmitData, VariantSelectSubmitData, UnsaveAlertOptions, ListSelectOptions, VariantSelectOptions, QuickBuySubmitData, QuickBuyOptions, } from "./swish-ui/types";
|
|
102
|
+
export type * from "./options/types";
|
|
103
|
+
export type { ShopBridge } from "./utils/shop-bridge";
|