@tiledev/sdk-shopify 0.9.0 → 0.10.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/README.md +650 -50
- package/dist/alertSettings.d.ts.map +1 -1
- package/dist/alertSettings.js +2 -0
- package/dist/alertSettings.js.map +1 -1
- package/dist/attribution.d.ts +21 -0
- package/dist/attribution.d.ts.map +1 -1
- package/dist/attribution.js +17 -0
- package/dist/attribution.js.map +1 -1
- package/dist/auth/pkce.d.ts +30 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +128 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/session.d.ts +118 -0
- package/dist/auth/session.d.ts.map +1 -0
- package/dist/auth/session.js +896 -0
- package/dist/auth/session.js.map +1 -0
- package/dist/auth/storeCredit.d.ts +64 -0
- package/dist/auth/storeCredit.d.ts.map +1 -0
- package/dist/auth/storeCredit.js +274 -0
- package/dist/auth/storeCredit.js.map +1 -0
- package/dist/cart.d.ts +25 -1
- package/dist/cart.d.ts.map +1 -1
- package/dist/cart.js +95 -2
- package/dist/cart.js.map +1 -1
- package/dist/cartPolicy.js +4 -4
- package/dist/checkout.d.ts +123 -0
- package/dist/checkout.d.ts.map +1 -0
- package/dist/checkout.js +205 -0
- package/dist/checkout.js.map +1 -0
- package/dist/customer.d.ts.map +1 -1
- package/dist/customer.js +8 -0
- package/dist/customer.js.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +74 -2
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +2 -0
- package/dist/messages.js.map +1 -1
- package/dist/money.d.ts +16 -0
- package/dist/money.d.ts.map +1 -1
- package/dist/money.js +55 -0
- package/dist/money.js.map +1 -1
- package/dist/orders.d.ts +99 -0
- package/dist/orders.d.ts.map +1 -0
- package/dist/orders.js +439 -0
- package/dist/orders.js.map +1 -0
- package/dist/productPage.d.ts +100 -0
- package/dist/productPage.d.ts.map +1 -0
- package/dist/productPage.js +298 -0
- package/dist/productPage.js.map +1 -0
- package/dist/productStore.d.ts +1 -1
- package/dist/productStore.d.ts.map +1 -1
- package/dist/productStore.js +63 -5
- package/dist/productStore.js.map +1 -1
- package/dist/products.d.ts.map +1 -1
- package/dist/products.js +15 -3
- package/dist/products.js.map +1 -1
- package/dist/purchaseRules.d.ts +74 -0
- package/dist/purchaseRules.d.ts.map +1 -0
- package/dist/purchaseRules.js +73 -0
- package/dist/purchaseRules.js.map +1 -0
- package/dist/queries.d.ts +15 -13
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +43 -7
- package/dist/queries.js.map +1 -1
- package/dist/react/ShopifyProvider.d.ts +167 -25
- package/dist/react/ShopifyProvider.d.ts.map +1 -1
- package/dist/react/ShopifyProvider.js +352 -207
- package/dist/react/ShopifyProvider.js.map +1 -1
- package/dist/react/appForeground.d.ts +6 -0
- package/dist/react/appForeground.d.ts.map +1 -0
- package/dist/react/appForeground.js +19 -0
- package/dist/react/appForeground.js.map +1 -0
- package/dist/react/appForeground.native.d.ts +2 -0
- package/dist/react/appForeground.native.d.ts.map +1 -0
- package/dist/react/appForeground.native.js +23 -0
- package/dist/react/appForeground.native.js.map +1 -0
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +23 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/tileCreditClient.d.ts +4 -0
- package/dist/react/tileCreditClient.d.ts.map +1 -0
- package/dist/react/tileCreditClient.js +27 -0
- package/dist/react/tileCreditClient.js.map +1 -0
- package/dist/react/useAppDiscountCode.d.ts +19 -0
- package/dist/react/useAppDiscountCode.d.ts.map +1 -0
- package/dist/react/useAppDiscountCode.js +44 -0
- package/dist/react/useAppDiscountCode.js.map +1 -0
- package/dist/react/useCartStoreCredit.d.ts +25 -0
- package/dist/react/useCartStoreCredit.d.ts.map +1 -0
- package/dist/react/useCartStoreCredit.js +292 -0
- package/dist/react/useCartStoreCredit.js.map +1 -0
- package/dist/react/useOrders.d.ts +104 -0
- package/dist/react/useOrders.d.ts.map +1 -0
- package/dist/react/useOrders.js +287 -0
- package/dist/react/useOrders.js.map +1 -0
- package/dist/react/useProduct.d.ts.map +1 -1
- package/dist/react/useProduct.js +1 -9
- package/dist/react/useProduct.js.map +1 -1
- package/dist/react/useProductPage.d.ts +148 -0
- package/dist/react/useProductPage.d.ts.map +1 -0
- package/dist/react/useProductPage.js +178 -0
- package/dist/react/useProductPage.js.map +1 -0
- package/dist/react/useProductRecommendations.d.ts +27 -0
- package/dist/react/useProductRecommendations.d.ts.map +1 -0
- package/dist/react/useProductRecommendations.js +76 -0
- package/dist/react/useProductRecommendations.js.map +1 -0
- package/dist/react/useStoreCredit.d.ts +58 -0
- package/dist/react/useStoreCredit.d.ts.map +1 -0
- package/dist/react/useStoreCredit.js +209 -0
- package/dist/react/useStoreCredit.js.map +1 -0
- package/dist/react/useTileCredit.d.ts +4 -3
- package/dist/react/useTileCredit.d.ts.map +1 -1
- package/dist/react/useTileCredit.js +63 -55
- package/dist/react/useTileCredit.js.map +1 -1
- package/dist/shopify.d.ts.map +1 -1
- package/dist/shopify.js +2 -0
- package/dist/shopify.js.map +1 -1
- package/dist/storedList.d.ts +27 -0
- package/dist/storedList.d.ts.map +1 -0
- package/dist/storedList.js +152 -0
- package/dist/storedList.js.map +1 -0
- package/dist/tileCredit.d.ts +25 -10
- package/dist/tileCredit.d.ts.map +1 -1
- package/dist/tileCredit.js +97 -45
- package/dist/tileCredit.js.map +1 -1
- package/dist/types.d.ts +407 -34
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/types.js.map +1 -1
- package/dist/variants.d.ts.map +1 -1
- package/dist/variants.js +4 -3
- package/dist/variants.js.map +1 -1
- package/dist/waitlist.d.ts +4 -0
- package/dist/waitlist.d.ts.map +1 -0
- package/dist/waitlist.js +213 -0
- package/dist/waitlist.js.map +1 -0
- package/dist/wishlist.d.ts.map +1 -1
- package/dist/wishlist.js +70 -47
- package/dist/wishlist.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { type CheckoutPreparation, type PrepareCheckoutOptions } from "../checkout";
|
|
2
3
|
import type { AttributionSource } from "../attribution";
|
|
3
|
-
import
|
|
4
|
+
import { type ProfileChanges, type SignupInput } from "../auth/session";
|
|
5
|
+
import type { AlertMessageKey, AuthMethod, AuthOptions, AlertMessages, Cart, CartLine, CartAttribute, CartLineAttribute, CartLineGuard, CartLineInput, CartPolicy, CartWriteResult, Customer, MessageResolver, Product, ShopifyConfig, SignInAttempt, StoreCreditOptions, WaitlistEntryInput, WaitlistItem, WishlistItem, WishlistStorageAdapter } from "../types";
|
|
4
6
|
interface CartState {
|
|
5
7
|
cart: Cart | null;
|
|
6
8
|
loading: boolean;
|
|
@@ -18,8 +20,15 @@ interface CartState {
|
|
|
18
20
|
/**
|
|
19
21
|
* Returns the resulting cart, `null` when nothing landed. One unsellable line fails the whole
|
|
20
22
|
* `cartLinesAdd`, so a rejected batch is retried line by line and the successes are kept.
|
|
23
|
+
*
|
|
24
|
+
* `options.quiet`: the caller reports the outcome itself. Every `cartGuard.beforeAdd` is passed it
|
|
25
|
+
* (so the guard says nothing about a refusal), and the one `cart:outOfStock` the line-by-line retry
|
|
26
|
+
* raises for the lines Shopify refused is not emitted. `cart:add` (something landed) and
|
|
27
|
+
* `cart:limitExceeded` (the line limit refused the whole batch) still are.
|
|
21
28
|
*/
|
|
22
|
-
addLines: (inputs: CartLineInput[]
|
|
29
|
+
addLines: (inputs: CartLineInput[], options?: {
|
|
30
|
+
quiet?: boolean;
|
|
31
|
+
}) => Promise<Cart | null>;
|
|
23
32
|
/**
|
|
24
33
|
* `false` when a `cartGuard` cancelled the increase. `attributes` REPLACE the line's set —
|
|
25
34
|
* Shopify does not merge them — so omit the argument to leave them untouched. `opts.source` is
|
|
@@ -46,6 +55,25 @@ interface CartState {
|
|
|
46
55
|
countryCode?: string;
|
|
47
56
|
customerAccessToken?: string;
|
|
48
57
|
}) => Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Adds gift-card codes to the cart and keeps the cards already on it (`cartGiftCardCodesAdd`), in
|
|
60
|
+
* the cart's write queue like every other write. Returns the cart; null when there is no cart yet
|
|
61
|
+
* (none is created for this).
|
|
62
|
+
*
|
|
63
|
+
* Shopify takes a gift card only on a cart with a country, so a cart without one gets the
|
|
64
|
+
* provider's `config.country` (else the shop's) first, keeping its email and, when signed in, the
|
|
65
|
+
* shopper's link. A cart that has a country keeps its buyer identity untouched.
|
|
66
|
+
*
|
|
67
|
+
* Throws a `ShopifyError` when Shopify refuses a code (its `userErrors`), and also when it answers
|
|
68
|
+
* without applying one, which it does without an error (`code: 'GIFT_CARD_NOT_APPLIED'`, the cart
|
|
69
|
+
* still updated). Gift cards change no lines, so `cartGuard` isn't asked.
|
|
70
|
+
*/
|
|
71
|
+
addGiftCardCodes: (codes: string[]) => Promise<Cart | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Takes the given gift cards off the cart by their `AppliedGiftCard.id` (not the code), leaving every
|
|
74
|
+
* other card on it, in the write queue. Null when there is no cart.
|
|
75
|
+
*/
|
|
76
|
+
removeGiftCards: (appliedGiftCardIds: string[]) => Promise<Cart | null>;
|
|
49
77
|
/** Re-reads the cart and returns it, so a caller need not wait for the re-render. */
|
|
50
78
|
refresh: () => Promise<Cart | null>;
|
|
51
79
|
/**
|
|
@@ -82,45 +110,96 @@ interface WishlistState {
|
|
|
82
110
|
clear: () => Promise<void>;
|
|
83
111
|
refresh: () => Promise<void>;
|
|
84
112
|
}
|
|
113
|
+
/** The sizes or colours the shopper is waiting on, kept on the device (see `WaitlistItem`). */
|
|
114
|
+
interface WaitlistState {
|
|
115
|
+
items: WaitlistItem[];
|
|
116
|
+
/** The variant ids waited on, in `items` order. The same array until the list changes. */
|
|
117
|
+
ids: string[];
|
|
118
|
+
count: number;
|
|
119
|
+
has: (variantId: string) => boolean;
|
|
120
|
+
/** Emits `waitlist:add` ("Added to waitlist"). */
|
|
121
|
+
add: (entry: WaitlistEntryInput) => Promise<void>;
|
|
122
|
+
/** Emits `waitlist:remove`, which carries no message: removing raises no toast. */
|
|
123
|
+
remove: (variantId: string) => Promise<void>;
|
|
124
|
+
/** Fetches every variant again; rejects, changing nothing, when it can't (offline). */
|
|
125
|
+
refresh: () => Promise<void>;
|
|
126
|
+
}
|
|
85
127
|
/**
|
|
86
|
-
* The
|
|
87
|
-
* `
|
|
88
|
-
*
|
|
128
|
+
* The shopper's session, for both ways of signing in: email and password (`login`, `signup`,
|
|
129
|
+
* `recoverPassword`) and Shopify's web sign-in (`signIn`, `startSignIn`). `auth.method` on the
|
|
130
|
+
* provider says which one the app offers now; `sessionKind` says which one the current session is.
|
|
131
|
+
* The session itself lives in `auth/session.ts`; base cases in test/auth-*.test.mjs.
|
|
89
132
|
*/
|
|
90
133
|
interface CustomerState {
|
|
91
134
|
customer: Customer | null;
|
|
92
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* A session exists. Offline on app open it can be true while `customer` is still null: the
|
|
137
|
+
* profile loads on the next `refresh()`.
|
|
138
|
+
*/
|
|
93
139
|
loggedIn: boolean;
|
|
94
|
-
/** The
|
|
140
|
+
/** The current access token, possibly stale. Callers that send it somewhere use `getAccessToken()`. */
|
|
95
141
|
accessToken: string | null;
|
|
96
142
|
loading: boolean;
|
|
97
|
-
/**
|
|
143
|
+
/** Reading a stored session on app open, as distinct from "signed out". */
|
|
98
144
|
restoring: boolean;
|
|
99
|
-
/**
|
|
145
|
+
/** Which sign-in the app offers now: `auth.method`, `password` when unset. */
|
|
146
|
+
method: AuthMethod;
|
|
147
|
+
/** How the current session was signed in; null when signed out. */
|
|
148
|
+
sessionKind: AuthMethod | null;
|
|
149
|
+
/** Password sign-in. `false` on bad credentials, which emits `auth:loginFailed`. Everything else throws. */
|
|
100
150
|
login: (email: string, password: string) => Promise<boolean>;
|
|
101
|
-
signup: (input:
|
|
102
|
-
|
|
103
|
-
password: string;
|
|
104
|
-
firstName?: string;
|
|
105
|
-
lastName?: string;
|
|
106
|
-
acceptsMarketing?: boolean;
|
|
107
|
-
}) => Promise<boolean>;
|
|
108
|
-
/** Always resolves — Shopify refusing the token delete still ends the local session. */
|
|
151
|
+
signup: (input: SignupInput) => Promise<boolean>;
|
|
152
|
+
/** Always resolves: Shopify being unreachable still ends the local session. */
|
|
109
153
|
logout: () => Promise<void>;
|
|
110
154
|
/** Emits `auth:recoverSent`. Shopify does not reveal whether the email exists. */
|
|
111
155
|
recoverPassword: (email: string) => Promise<void>;
|
|
112
|
-
/** Re-reads the profile
|
|
156
|
+
/** Re-reads the profile. Null when signed out or the session ended. */
|
|
113
157
|
refresh: () => Promise<Customer | null>;
|
|
158
|
+
/**
|
|
159
|
+
* Changes the name and email marketing consent, for either kind of session, sending only what
|
|
160
|
+
* differs from `customer`. `true` once Shopify accepted it all, with `customer` showing the new
|
|
161
|
+
* values. `false` when signed out, refused or offline (logged with `console.warn`). Never throws.
|
|
162
|
+
*/
|
|
163
|
+
updateProfile: (changes: ProfileChanges) => Promise<boolean>;
|
|
164
|
+
/**
|
|
165
|
+
* Shopify web sign-in in the system browser sheet (`auth.openAuthSession`). `false` when the
|
|
166
|
+
* shopper backs out (no event) or Shopify refuses (`auth:loginFailed`). Throws when offline.
|
|
167
|
+
*/
|
|
168
|
+
signIn: () => Promise<boolean>;
|
|
169
|
+
/** Shopify web sign-in in the app's own web view. See `SignInAttempt`. */
|
|
170
|
+
startSignIn: () => SignInAttempt;
|
|
171
|
+
/** A usable access token, refreshed when needed. Null when signed out or the session ended. */
|
|
172
|
+
getAccessToken: () => Promise<string | null>;
|
|
173
|
+
/**
|
|
174
|
+
* A token renewed now, even if the current one looks valid: for a service that just answered 401
|
|
175
|
+
* (Tile Credit does). A Shopify session refreshes, sharing a refresh already on its way; a password
|
|
176
|
+
* session can't renew, so null. It never signs the shopper out; only Shopify refusing the refresh
|
|
177
|
+
* ends the session, as it would anyway. Throws when offline.
|
|
178
|
+
*/
|
|
179
|
+
renewAccessToken: () => Promise<string | null>;
|
|
180
|
+
/** A Customer Account API GraphQL call for the signed-in shopper (`shopify` sessions only). */
|
|
181
|
+
request: <T>(query: string, variables?: Record<string, unknown>) => Promise<T>;
|
|
114
182
|
}
|
|
115
183
|
/**
|
|
116
184
|
* Checkout is Shopify-hosted, so the SDK cannot see the outcome itself. The host
|
|
117
185
|
* webview reports it here and gets the configured copy on the event, rather than
|
|
118
186
|
* every app hard-coding "Your order has been placed".
|
|
119
187
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
188
|
+
* Before it opens, `prepare` gets the cart ready (SDK move 6); the page's address says when the order
|
|
189
|
+
* is placed (`isOrderPlacedUrl`, `../checkout`).
|
|
122
190
|
*/
|
|
123
191
|
interface CheckoutState {
|
|
192
|
+
/**
|
|
193
|
+
* Gets the cart ready for checkout: reads it again, checks for a reservation that ran out
|
|
194
|
+
* (`options.hasLapsedHold`), attaches the signed-in shopper with the cart's country, lands the
|
|
195
|
+
* cart's attribution and the provider's `cartAttributes` (with 0.9.1's attribution), and reports
|
|
196
|
+
* the start. Answers `ready`,
|
|
197
|
+
* `empty`, `lapsedHold` or `failed` (`prepareCheckout` in `../checkout` has the rule). Never throws.
|
|
198
|
+
* Going to the checkout page is the app's, on `ready`.
|
|
199
|
+
*/
|
|
200
|
+
prepare: (options?: PrepareCheckoutOptions) => Promise<CheckoutPreparation>;
|
|
201
|
+
/** This hook's `prepare` is running (for a spinner on the button that started it). */
|
|
202
|
+
preparing: boolean;
|
|
124
203
|
/**
|
|
125
204
|
* Call as checkout opens for the shared cart. A checked-out cart reads back null exactly like an
|
|
126
205
|
* expired one, so without this a missed `reportOrderPlaced` would refill the cart on next launch
|
|
@@ -140,11 +219,19 @@ interface ShopifyContextType {
|
|
|
140
219
|
error: string | null;
|
|
141
220
|
cart: CartState;
|
|
142
221
|
wishlist: WishlistState;
|
|
222
|
+
waitlist: WaitlistState;
|
|
143
223
|
customer: CustomerState;
|
|
144
|
-
|
|
224
|
+
/** `useCheckout()` adds `preparing`, which is each caller's own. */
|
|
225
|
+
checkout: Omit<CheckoutState, "preparing">;
|
|
226
|
+
/** The app's store-credit choice, read by `useStoreCredit`. */
|
|
227
|
+
storeCredit: StoreCreditOptions | null;
|
|
145
228
|
/** Resolved alert copy, for labelling UI that isn't a toast — e.g. the
|
|
146
229
|
* empty-wishlist placeholder (`wishlist.empty`), which has no event. */
|
|
147
230
|
message: (key: AlertMessageKey) => string;
|
|
231
|
+
/** Every event the provider raises, for `useShopifyEvents` (0.10). */
|
|
232
|
+
events: {
|
|
233
|
+
subscribe: (listener: (event: ShopifyEvent) => void) => () => void;
|
|
234
|
+
};
|
|
148
235
|
}
|
|
149
236
|
/**
|
|
150
237
|
* Everything the host may want to tell the shopper about. One event per alert the
|
|
@@ -154,7 +241,9 @@ interface ShopifyContextType {
|
|
|
154
241
|
* signal as much as a success does, and wrapping every call in try/catch to find
|
|
155
242
|
* out is what this replaces. Errors still throw for callers that want them.
|
|
156
243
|
*/
|
|
157
|
-
export type ShopifyEventType = "cart:add" | "cart:update" | "cart:remove" | "cart:limitExceeded" | "cart:outOfStock" | "cart:buyerIdentity" | "wishlist:add" | "wishlist:remove" | "
|
|
244
|
+
export type ShopifyEventType = "cart:add" | "cart:update" | "cart:remove" | "cart:limitExceeded" | "cart:stockLimit" | "cart:outOfStock" | "cart:buyerIdentity" | "wishlist:add" | "wishlist:remove" | "waitlist:add" | "waitlist:remove" | "auth:loginSuccess" | "auth:loginFailed" | "auth:signup" | "auth:logout" | "auth:recoverSent"
|
|
245
|
+
/** A session Shopify stopped accepting, while the app was in use. No message: a host may route to sign-in. */
|
|
246
|
+
| "auth:sessionExpired" | "checkout:orderPlaced" | "checkout:paymentFailed";
|
|
158
247
|
export interface ShopifyEvent {
|
|
159
248
|
type: ShopifyEventType;
|
|
160
249
|
/** How to present it — a toast tone, not a log level. */
|
|
@@ -169,6 +258,32 @@ export interface ShopifyEvent {
|
|
|
169
258
|
messageKey?: AlertMessageKey;
|
|
170
259
|
/** Present on failures. `ShopifyError.errors` carries the Shopify codes. */
|
|
171
260
|
error?: unknown;
|
|
261
|
+
/**
|
|
262
|
+
* The cart after the write, on `cart:add`, `cart:update` and `cart:remove` (0.10). A listener can
|
|
263
|
+
* report from it straight away: React's `useCart().cart` hasn't caught up when the event arrives.
|
|
264
|
+
*/
|
|
265
|
+
cart?: Cart;
|
|
266
|
+
/**
|
|
267
|
+
* The lines the write changed, on the same three events (0.10): usually one; an `addLines` that
|
|
268
|
+
* landed several lines lists each once. Empty when the line wasn't in the cart the write started from.
|
|
269
|
+
*/
|
|
270
|
+
changedLines?: CartLineChange[];
|
|
271
|
+
/** The product saved or unsaved, on `wishlist:add` and `wishlist:remove` (0.10). */
|
|
272
|
+
productId?: string;
|
|
273
|
+
/**
|
|
274
|
+
* The signed-in customer, on `auth:loginSuccess` (0.10). Null when their profile hadn't loaded when
|
|
275
|
+
* the sign-in finished: `useCustomer().customer` has it once it does.
|
|
276
|
+
*/
|
|
277
|
+
customer?: Customer | null;
|
|
278
|
+
/** How that session signed in (`useCustomer().sessionKind`), on `auth:loginSuccess` (0.10). */
|
|
279
|
+
sessionKind?: AuthMethod | null;
|
|
280
|
+
}
|
|
281
|
+
/** One cart line a write changed, on `ShopifyEvent.changedLines`. */
|
|
282
|
+
export interface CartLineChange {
|
|
283
|
+
/** The line after the write. For a line the write took out of the cart, the line as it was. */
|
|
284
|
+
line: CartLine;
|
|
285
|
+
/** Units added (above 0) or taken away (below 0). 0 when only the line's attributes changed. */
|
|
286
|
+
quantityChange: number;
|
|
172
287
|
}
|
|
173
288
|
export interface ShopifyProviderProps {
|
|
174
289
|
children: ReactNode;
|
|
@@ -184,6 +299,14 @@ export interface ShopifyProviderProps {
|
|
|
184
299
|
cartGuard?: CartLineGuard;
|
|
185
300
|
/** See `WishlistInitOptions.keepDeleted`. Recommended for a shopper-facing wishlist. */
|
|
186
301
|
wishlistKeepDeleted?: boolean;
|
|
302
|
+
/** See `WishlistInitOptions.storageKey`: an app moving from Apptile's engine passes its old key. */
|
|
303
|
+
wishlistStorageKey?: string;
|
|
304
|
+
/** See `WishlistInitOptions.migrateFrom`: keys an earlier app kept its wishlist under. */
|
|
305
|
+
wishlistMigrateFrom?: string[];
|
|
306
|
+
/** See `WaitlistInitOptions.storageKey`: an app moving from Apptile's engine passes its old key. */
|
|
307
|
+
waitlistStorageKey?: string;
|
|
308
|
+
/** See `WaitlistInitOptions.migrateFrom`: keys an earlier app kept its waitlist under. */
|
|
309
|
+
waitlistMigrateFrom?: string[];
|
|
187
310
|
/**
|
|
188
311
|
* Alert copy, outside `config` so a Live Layer publish can change it without
|
|
189
312
|
* re-running `init` (which would re-load the shop and re-create the cart).
|
|
@@ -204,6 +327,13 @@ export interface ShopifyProviderProps {
|
|
|
204
327
|
* sets it here or the cart goes out anonymous.
|
|
205
328
|
*/
|
|
206
329
|
cartAttributes?: CartAttribute[];
|
|
330
|
+
/**
|
|
331
|
+
* How shoppers sign in. Unset: email and password only, as before. `method` can change while the
|
|
332
|
+
* app runs: `password` for App Store review, `shopify` for shoppers.
|
|
333
|
+
*/
|
|
334
|
+
auth?: AuthOptions;
|
|
335
|
+
/** Where store credit comes from, for `useStoreCredit`. Unset: the app shows none. */
|
|
336
|
+
storeCredit?: StoreCreditOptions;
|
|
207
337
|
/**
|
|
208
338
|
* Records where the cart's units came from (live show, replay, or the rest of the app) in the
|
|
209
339
|
* `_apptile_attribution` cart attribute, after each line write lands. Off by default.
|
|
@@ -212,18 +342,30 @@ export interface ShopifyProviderProps {
|
|
|
212
342
|
enabled: boolean;
|
|
213
343
|
};
|
|
214
344
|
}
|
|
215
|
-
export declare function ShopifyProvider({ children, config, storage, onEvent, cartGuard, wishlistKeepDeleted, messages, translate, cartPolicy, cartAttributes, attribution, }: ShopifyProviderProps): import("react").JSX.Element;
|
|
345
|
+
export declare function ShopifyProvider({ children, config, storage, onEvent, cartGuard, wishlistKeepDeleted, wishlistStorageKey, wishlistMigrateFrom, waitlistStorageKey, waitlistMigrateFrom, messages, translate, cartPolicy, cartAttributes, auth, storeCredit, attribution, }: ShopifyProviderProps): import("react").JSX.Element;
|
|
216
346
|
export declare function useShopify(): ShopifyContextType;
|
|
217
347
|
export declare function useCart(): CartState;
|
|
218
348
|
export declare function useWishlist(): WishlistState;
|
|
349
|
+
export declare function useWaitlist(): WaitlistState;
|
|
219
350
|
/** Customer session — the source of the four Login alerts. */
|
|
220
351
|
export declare function useCustomer(): CustomerState;
|
|
221
|
-
/**
|
|
352
|
+
/**
|
|
353
|
+
* Gets the cart ready before checkout opens (`prepare`, with this caller's own `preparing`), and
|
|
354
|
+
* reports a hosted-checkout outcome so the two Checkout alerts can fire.
|
|
355
|
+
*/
|
|
222
356
|
export declare function useCheckout(): CheckoutState;
|
|
357
|
+
/**
|
|
358
|
+
* Hears every event the provider raises, from anywhere inside it (0.10): the same events `onEvent`
|
|
359
|
+
* gets, told right after it, in the order they happen. Cart events carry the cart and the lines they
|
|
360
|
+
* changed, so a listener reports from the event rather than waiting for `useCart()` to catch up. The
|
|
361
|
+
* listener is read when an event fires, so a new function each render is fine. It starts hearing once
|
|
362
|
+
* the component has mounted and stops when it unmounts.
|
|
363
|
+
*/
|
|
364
|
+
export declare function useShopifyEvents(listener: (event: ShopifyEvent) => void): void;
|
|
223
365
|
/**
|
|
224
366
|
* Resolved alert copy, for UI that isn't a toast — the empty-wishlist
|
|
225
367
|
* placeholder (`wishlist.empty`) is configurable but has no event.
|
|
226
368
|
*/
|
|
227
369
|
export declare function useShopifyMessage(): (key: AlertMessageKey) => string;
|
|
228
|
-
export type { CartState, WishlistState, CustomerState, CheckoutState };
|
|
370
|
+
export type { CartState, WishlistState, WaitlistState, CustomerState, CheckoutState };
|
|
229
371
|
//# sourceMappingURL=ShopifyProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShopifyProvider.d.ts","sourceRoot":"","sources":["../../src/react/ShopifyProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAOV,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ShopifyProvider.d.ts","sourceRoot":"","sources":["../../src/react/ShopifyProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAOV,MAAM,OAAO,CAAC;AAIf,OAAO,EAAmB,KAAK,mBAAmB,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOxD,OAAO,EAA+C,KAAK,cAAc,EAAqB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxI,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EAGb,UAAU,EACV,eAAe,EACf,QAAQ,EACR,eAAe,EACf,OAAO,EACP,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACvB,MAAM,UAAU,CAAC;AA4BlB,UAAU,SAAS;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;OAIG;IACH,OAAO,EAAa,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IACvE;;;;;;;;OAQG;IACH,QAAQ,EAAY,CAAC,MAAM,EAAE,aAAa,EAAE,EA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