@tiledev/sdk-shopify 0.9.1 → 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.
Files changed (143) hide show
  1. package/README.md +650 -50
  2. package/dist/alertSettings.d.ts.map +1 -1
  3. package/dist/alertSettings.js +2 -0
  4. package/dist/alertSettings.js.map +1 -1
  5. package/dist/attribution.d.ts +21 -0
  6. package/dist/attribution.d.ts.map +1 -1
  7. package/dist/attribution.js +17 -0
  8. package/dist/attribution.js.map +1 -1
  9. package/dist/auth/pkce.d.ts +30 -0
  10. package/dist/auth/pkce.d.ts.map +1 -0
  11. package/dist/auth/pkce.js +128 -0
  12. package/dist/auth/pkce.js.map +1 -0
  13. package/dist/auth/session.d.ts +118 -0
  14. package/dist/auth/session.d.ts.map +1 -0
  15. package/dist/auth/session.js +896 -0
  16. package/dist/auth/session.js.map +1 -0
  17. package/dist/auth/storeCredit.d.ts +64 -0
  18. package/dist/auth/storeCredit.d.ts.map +1 -0
  19. package/dist/auth/storeCredit.js +274 -0
  20. package/dist/auth/storeCredit.js.map +1 -0
  21. package/dist/cart.d.ts +25 -1
  22. package/dist/cart.d.ts.map +1 -1
  23. package/dist/cart.js +95 -2
  24. package/dist/cart.js.map +1 -1
  25. package/dist/cartPolicy.js +4 -4
  26. package/dist/checkout.d.ts +123 -0
  27. package/dist/checkout.d.ts.map +1 -0
  28. package/dist/checkout.js +205 -0
  29. package/dist/checkout.js.map +1 -0
  30. package/dist/customer.d.ts.map +1 -1
  31. package/dist/customer.js +8 -0
  32. package/dist/customer.js.map +1 -1
  33. package/dist/index.d.ts +12 -4
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +74 -2
  36. package/dist/index.js.map +1 -1
  37. package/dist/messages.d.ts.map +1 -1
  38. package/dist/messages.js +2 -0
  39. package/dist/messages.js.map +1 -1
  40. package/dist/money.d.ts +16 -0
  41. package/dist/money.d.ts.map +1 -1
  42. package/dist/money.js +55 -0
  43. package/dist/money.js.map +1 -1
  44. package/dist/orders.d.ts +99 -0
  45. package/dist/orders.d.ts.map +1 -0
  46. package/dist/orders.js +439 -0
  47. package/dist/orders.js.map +1 -0
  48. package/dist/productPage.d.ts +100 -0
  49. package/dist/productPage.d.ts.map +1 -0
  50. package/dist/productPage.js +298 -0
  51. package/dist/productPage.js.map +1 -0
  52. package/dist/productStore.d.ts +1 -1
  53. package/dist/productStore.d.ts.map +1 -1
  54. package/dist/productStore.js +63 -5
  55. package/dist/productStore.js.map +1 -1
  56. package/dist/products.d.ts.map +1 -1
  57. package/dist/products.js +15 -3
  58. package/dist/products.js.map +1 -1
  59. package/dist/purchaseRules.d.ts +74 -0
  60. package/dist/purchaseRules.d.ts.map +1 -0
  61. package/dist/purchaseRules.js +73 -0
  62. package/dist/purchaseRules.js.map +1 -0
  63. package/dist/queries.d.ts +15 -13
  64. package/dist/queries.d.ts.map +1 -1
  65. package/dist/queries.js +43 -7
  66. package/dist/queries.js.map +1 -1
  67. package/dist/react/ShopifyProvider.d.ts +167 -25
  68. package/dist/react/ShopifyProvider.d.ts.map +1 -1
  69. package/dist/react/ShopifyProvider.js +352 -207
  70. package/dist/react/ShopifyProvider.js.map +1 -1
  71. package/dist/react/appForeground.d.ts +6 -0
  72. package/dist/react/appForeground.d.ts.map +1 -0
  73. package/dist/react/appForeground.js +19 -0
  74. package/dist/react/appForeground.js.map +1 -0
  75. package/dist/react/appForeground.native.d.ts +2 -0
  76. package/dist/react/appForeground.native.d.ts.map +1 -0
  77. package/dist/react/appForeground.native.js +23 -0
  78. package/dist/react/appForeground.native.js.map +1 -0
  79. package/dist/react/index.d.ts +7 -1
  80. package/dist/react/index.d.ts.map +1 -1
  81. package/dist/react/index.js +23 -1
  82. package/dist/react/index.js.map +1 -1
  83. package/dist/react/tileCreditClient.d.ts +4 -0
  84. package/dist/react/tileCreditClient.d.ts.map +1 -0
  85. package/dist/react/tileCreditClient.js +27 -0
  86. package/dist/react/tileCreditClient.js.map +1 -0
  87. package/dist/react/useAppDiscountCode.d.ts +19 -0
  88. package/dist/react/useAppDiscountCode.d.ts.map +1 -0
  89. package/dist/react/useAppDiscountCode.js +44 -0
  90. package/dist/react/useAppDiscountCode.js.map +1 -0
  91. package/dist/react/useCartStoreCredit.d.ts +25 -0
  92. package/dist/react/useCartStoreCredit.d.ts.map +1 -0
  93. package/dist/react/useCartStoreCredit.js +292 -0
  94. package/dist/react/useCartStoreCredit.js.map +1 -0
  95. package/dist/react/useOrders.d.ts +104 -0
  96. package/dist/react/useOrders.d.ts.map +1 -0
  97. package/dist/react/useOrders.js +287 -0
  98. package/dist/react/useOrders.js.map +1 -0
  99. package/dist/react/useProduct.d.ts.map +1 -1
  100. package/dist/react/useProduct.js +1 -9
  101. package/dist/react/useProduct.js.map +1 -1
  102. package/dist/react/useProductPage.d.ts +148 -0
  103. package/dist/react/useProductPage.d.ts.map +1 -0
  104. package/dist/react/useProductPage.js +178 -0
  105. package/dist/react/useProductPage.js.map +1 -0
  106. package/dist/react/useProductRecommendations.d.ts +27 -0
  107. package/dist/react/useProductRecommendations.d.ts.map +1 -0
  108. package/dist/react/useProductRecommendations.js +76 -0
  109. package/dist/react/useProductRecommendations.js.map +1 -0
  110. package/dist/react/useStoreCredit.d.ts +58 -0
  111. package/dist/react/useStoreCredit.d.ts.map +1 -0
  112. package/dist/react/useStoreCredit.js +209 -0
  113. package/dist/react/useStoreCredit.js.map +1 -0
  114. package/dist/react/useTileCredit.d.ts +4 -3
  115. package/dist/react/useTileCredit.d.ts.map +1 -1
  116. package/dist/react/useTileCredit.js +63 -55
  117. package/dist/react/useTileCredit.js.map +1 -1
  118. package/dist/shopify.d.ts.map +1 -1
  119. package/dist/shopify.js +2 -0
  120. package/dist/shopify.js.map +1 -1
  121. package/dist/storedList.d.ts +27 -0
  122. package/dist/storedList.d.ts.map +1 -0
  123. package/dist/storedList.js +152 -0
  124. package/dist/storedList.js.map +1 -0
  125. package/dist/tileCredit.d.ts +25 -10
  126. package/dist/tileCredit.d.ts.map +1 -1
  127. package/dist/tileCredit.js +97 -45
  128. package/dist/tileCredit.js.map +1 -1
  129. package/dist/types.d.ts +407 -34
  130. package/dist/types.d.ts.map +1 -1
  131. package/dist/types.js +1 -2
  132. package/dist/types.js.map +1 -1
  133. package/dist/variants.d.ts.map +1 -1
  134. package/dist/variants.js +4 -3
  135. package/dist/variants.js.map +1 -1
  136. package/dist/waitlist.d.ts +4 -0
  137. package/dist/waitlist.d.ts.map +1 -0
  138. package/dist/waitlist.js +213 -0
  139. package/dist/waitlist.js.map +1 -0
  140. package/dist/wishlist.d.ts.map +1 -1
  141. package/dist/wishlist.js +70 -47
  142. package/dist/wishlist.js.map +1 -1
  143. package/package.json +2 -2
package/dist/orders.js ADDED
@@ -0,0 +1,439 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ORDER_CLOCK_LEEWAY_MS = exports.STOREFRONT_ORDER_DETAIL_QUERY = exports.STOREFRONT_ORDER_IDS_QUERY = exports.STOREFRONT_ORDER_HISTORY_QUERY = exports.ACCOUNT_ORDER_DETAIL_QUERY = exports.ACCOUNT_ORDER_HISTORY_QUERY = exports.ORDER_LINES_READ = exports.LIST_LINES_COUNTED = void 0;
4
+ exports.orderProgress = orderProgress;
5
+ exports.placedSince = placedSince;
6
+ exports.customerAccountOrders = customerAccountOrders;
7
+ exports.storefrontOrders = storefrontOrders;
8
+ exports.withFreshFirstPage = withFreshFirstPage;
9
+ exports.withNextPage = withNextPage;
10
+ exports.planBuyAgain = planBuyAgain;
11
+ /**
12
+ * The signed-in shopper's orders, for `useOrders` and `useOrder` (react/useOrders.ts), from the API
13
+ * their session reads (`CustomerState.sessionKind`):
14
+ *
15
+ * - `shopify`: the Customer Account API (`customer.orders`, `order(id:)`), as production Amber did.
16
+ * - `password`: the Storefront API (`customer(customerAccessToken:) { orders }`).
17
+ *
18
+ * Both answer in the same shapes (`OrderSummary`, `OrderDetails`), so a screen doesn't care which
19
+ * sign-in it was. Newest first on both, by `processedAt`: the date the screens show. (Production
20
+ * sorted by ID; an imported order's `processedAt` can be older than its ID suggests.)
21
+ *
22
+ * Framework-free. Tested in test/orders.test.mjs.
23
+ */
24
+ const client_1 = require("./client");
25
+ const productPage_1 = require("./productPage");
26
+ const types_1 = require("./types");
27
+ /**
28
+ * Lines counted per order in a list, for `itemCount`. A list needs only the quantities, and this keeps
29
+ * a page of 25 near 850 Customer Account API cost points by Shopify's published cost rules (that API
30
+ * charges per field read, from 7,500 points per shopper and store).
31
+ */
32
+ exports.LIST_LINES_COUNTED = 30;
33
+ /** Lines read for one order. */
34
+ exports.ORDER_LINES_READ = 100;
35
+ // ── Customer Account API (Shopify sign-in) ─────────────────────────────────
36
+ exports.ACCOUNT_ORDER_HISTORY_QUERY = `
37
+ query OrderHistory($first: Int!, $after: String) {
38
+ customer {
39
+ orders(first: $first, after: $after, sortKey: PROCESSED_AT, reverse: true) {
40
+ pageInfo { hasNextPage endCursor }
41
+ nodes {
42
+ id
43
+ name
44
+ processedAt
45
+ cancelledAt
46
+ fulfillmentStatus
47
+ statusPageUrl
48
+ totalPrice { amount currencyCode }
49
+ lineItems(first: ${exports.LIST_LINES_COUNTED}) { nodes { quantity } }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ `;
55
+ exports.ACCOUNT_ORDER_DETAIL_QUERY = `
56
+ query OrderDetail($id: ID!) {
57
+ order(id: $id) {
58
+ id
59
+ name
60
+ processedAt
61
+ cancelledAt
62
+ fulfillmentStatus
63
+ statusPageUrl
64
+ totalPrice { amount currencyCode }
65
+ subtotal { amount currencyCode }
66
+ totalShipping { amount currencyCode }
67
+ totalTax { amount currencyCode }
68
+ totalRefunded { amount currencyCode }
69
+ discountApplications(first: 10) { nodes { ... on DiscountCodeApplication { code } } }
70
+ lineItems(first: ${exports.ORDER_LINES_READ}) {
71
+ nodes {
72
+ title
73
+ variantTitle
74
+ quantity
75
+ variantId
76
+ image { url }
77
+ price { amount currencyCode }
78
+ totalPrice { amount currencyCode }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ `;
84
+ // ── Storefront API (email and password) ────────────────────────────────────
85
+ exports.STOREFRONT_ORDER_HISTORY_QUERY = `
86
+ query CustomerOrderHistory($accessToken: String!, $first: Int!, $after: String) {
87
+ customer(customerAccessToken: $accessToken) {
88
+ orders(first: $first, after: $after, sortKey: PROCESSED_AT, reverse: true) {
89
+ pageInfo { hasNextPage endCursor }
90
+ nodes {
91
+ id
92
+ name
93
+ processedAt
94
+ canceledAt
95
+ fulfillmentStatus
96
+ statusUrl
97
+ totalPrice { amount currencyCode }
98
+ lineItems(first: ${exports.LIST_LINES_COUNTED}) { nodes { quantity } }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ `;
104
+ /**
105
+ * The Storefront API has no order-by-id query, so one order is found in two cheap reads: its place in
106
+ * the list (ids only, 250 a page), then that one order, read after the cursor of the one before it.
107
+ */
108
+ exports.STOREFRONT_ORDER_IDS_QUERY = `
109
+ query CustomerOrderIds($accessToken: String!, $after: String) {
110
+ customer(customerAccessToken: $accessToken) {
111
+ orders(first: 250, after: $after, sortKey: PROCESSED_AT, reverse: true) {
112
+ pageInfo { hasNextPage endCursor }
113
+ edges { cursor node { id } }
114
+ }
115
+ }
116
+ }
117
+ `;
118
+ exports.STOREFRONT_ORDER_DETAIL_QUERY = `
119
+ query CustomerOrderDetail($accessToken: String!, $after: String) {
120
+ customer(customerAccessToken: $accessToken) {
121
+ orders(first: 1, after: $after, sortKey: PROCESSED_AT, reverse: true) {
122
+ nodes {
123
+ id
124
+ name
125
+ processedAt
126
+ canceledAt
127
+ fulfillmentStatus
128
+ statusUrl
129
+ totalPrice { amount currencyCode }
130
+ subtotalPrice { amount currencyCode }
131
+ totalShippingPrice { amount currencyCode }
132
+ totalTax { amount currencyCode }
133
+ totalRefunded { amount currencyCode }
134
+ discountApplications(first: 10) { nodes { ... on DiscountCodeApplication { code } } }
135
+ lineItems(first: ${exports.ORDER_LINES_READ}) {
136
+ nodes {
137
+ title
138
+ quantity
139
+ originalTotalPrice { amount currencyCode }
140
+ variant { id title image { url } }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+ `;
148
+ // ── Mapping ────────────────────────────────────────────────────────────────
149
+ /** Production Amber's status card rule: cancelled wins, then the fulfilment status. */
150
+ function orderProgress(cancelledAt, fulfillmentStatus) {
151
+ if (cancelledAt)
152
+ return 'cancelled';
153
+ if (fulfillmentStatus === 'FULFILLED')
154
+ return 'fulfilled';
155
+ if (fulfillmentStatus === 'PARTIALLY_FULFILLED')
156
+ return 'partiallyFulfilled';
157
+ return 'confirmed';
158
+ }
159
+ const nodesOf = (list) => { var _a; return ((_a = list === null || list === void 0 ? void 0 : list.nodes) !== null && _a !== void 0 ? _a : []).filter((node) => !!node); };
160
+ const toCents = (m) => { var _a; return Math.round((Number.parseFloat((_a = m === null || m === void 0 ? void 0 : m.amount) !== null && _a !== void 0 ? _a : '0') || 0) * 100); };
161
+ const fromCents = (cents, currencyCode) => ({ amount: (cents / 100).toFixed(2), currencyCode });
162
+ const copyMoney = (m) => (m ? { amount: m.amount, currencyCode: m.currencyCode } : null);
163
+ /** For the rows a screen shows only when they say something: a zero is null. */
164
+ const unlessZero = (m) => (m && toCents(m) !== 0 ? copyMoney(m) : null);
165
+ /** Shopify's name for the only variant of a product with one. */
166
+ const variantTitleOf = (title) => (title && title !== 'Default Title' ? title : null);
167
+ const codesOf = (list) => nodesOf(list).map((node) => node.code).filter((code) => !!code);
168
+ function fromAccount(raw) {
169
+ var _a, _b, _c, _d, _e;
170
+ return {
171
+ id: raw.id,
172
+ name: (_a = raw.name) !== null && _a !== void 0 ? _a : '',
173
+ processedAt: (_b = raw.processedAt) !== null && _b !== void 0 ? _b : '',
174
+ cancelledAt: (_c = raw.cancelledAt) !== null && _c !== void 0 ? _c : null,
175
+ fulfillmentStatus: (_d = raw.fulfillmentStatus) !== null && _d !== void 0 ? _d : null,
176
+ statusPageUrl: (_e = raw.statusPageUrl) !== null && _e !== void 0 ? _e : null,
177
+ totalPrice: raw.totalPrice,
178
+ lines: nodesOf(raw.lineItems).map((line) => {
179
+ var _a, _b, _c, _d, _e;
180
+ return ({
181
+ title: (_a = line.title) !== null && _a !== void 0 ? _a : '',
182
+ variantTitle: variantTitleOf(line.variantTitle),
183
+ quantity: (_b = line.quantity) !== null && _b !== void 0 ? _b : 0,
184
+ imageUrl: (_d = (_c = line.image) === null || _c === void 0 ? void 0 : _c.url) !== null && _d !== void 0 ? _d : null,
185
+ unitPrice: copyMoney(line.price),
186
+ totalPrice: copyMoney(line.totalPrice),
187
+ variantId: (_e = line.variantId) !== null && _e !== void 0 ? _e : null,
188
+ });
189
+ }),
190
+ netSubtotal: raw.subtotal,
191
+ totalShipping: raw.totalShipping,
192
+ totalTax: raw.totalTax,
193
+ totalRefunded: raw.totalRefunded,
194
+ discountCodes: codesOf(raw.discountApplications),
195
+ };
196
+ }
197
+ function fromStorefront(raw) {
198
+ var _a, _b, _c, _d, _e;
199
+ return {
200
+ id: raw.id,
201
+ name: (_a = raw.name) !== null && _a !== void 0 ? _a : '',
202
+ processedAt: (_b = raw.processedAt) !== null && _b !== void 0 ? _b : '',
203
+ cancelledAt: (_c = raw.canceledAt) !== null && _c !== void 0 ? _c : null,
204
+ fulfillmentStatus: (_d = raw.fulfillmentStatus) !== null && _d !== void 0 ? _d : null,
205
+ statusPageUrl: (_e = raw.statusUrl) !== null && _e !== void 0 ? _e : null,
206
+ totalPrice: raw.totalPrice,
207
+ lines: nodesOf(raw.lineItems).map((line) => {
208
+ var _a, _b, _c, _d, _e, _f, _g, _h;
209
+ const quantity = (_a = line.quantity) !== null && _a !== void 0 ? _a : 0;
210
+ const total = line.originalTotalPrice;
211
+ return {
212
+ title: (_b = line.title) !== null && _b !== void 0 ? _b : '',
213
+ variantTitle: variantTitleOf((_c = line.variant) === null || _c === void 0 ? void 0 : _c.title),
214
+ quantity,
215
+ imageUrl: (_f = (_e = (_d = line.variant) === null || _d === void 0 ? void 0 : _d.image) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : null,
216
+ // The Storefront API has no unit price on an order line; its pre-discount total is one times quantity.
217
+ unitPrice: total && quantity > 0 ? fromCents(Math.round(toCents(total) / quantity), total.currencyCode) : null,
218
+ totalPrice: copyMoney(total),
219
+ variantId: (_h = (_g = line.variant) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null,
220
+ };
221
+ }),
222
+ netSubtotal: raw.subtotalPrice,
223
+ totalShipping: raw.totalShippingPrice,
224
+ totalTax: raw.totalTax,
225
+ totalRefunded: raw.totalRefunded,
226
+ discountCodes: codesOf(raw.discountApplications),
227
+ };
228
+ }
229
+ function toSummary(order) {
230
+ var _a;
231
+ return {
232
+ id: order.id,
233
+ name: order.name,
234
+ processedAt: order.processedAt,
235
+ progress: orderProgress(order.cancelledAt, order.fulfillmentStatus),
236
+ cancelledAt: order.cancelledAt,
237
+ totalPrice: (_a = copyMoney(order.totalPrice)) !== null && _a !== void 0 ? _a : { amount: '0.00', currencyCode: '' },
238
+ itemCount: order.lines.reduce((sum, line) => sum + line.quantity, 0),
239
+ statusPageUrl: order.statusPageUrl,
240
+ };
241
+ }
242
+ /**
243
+ * Production Amber's totals: the subtotal shown is the lines before discounts, and the discount is the
244
+ * gap between that and Shopify's subtotal (which is after every discount, line or order level), so a
245
+ * whole-order code that lands on no single line is counted too.
246
+ */
247
+ function toDetails(order) {
248
+ var _a, _b, _c, _d;
249
+ const currencyCode = (_d = (_b = (_a = order.totalPrice) === null || _a === void 0 ? void 0 : _a.currencyCode) !== null && _b !== void 0 ? _b : (_c = order.netSubtotal) === null || _c === void 0 ? void 0 : _c.currencyCode) !== null && _d !== void 0 ? _d : '';
250
+ const lineTotals = order.lines.map((line) => line.totalPrice).filter((total) => !!total);
251
+ const itemsCents = lineTotals.reduce((sum, total) => sum + toCents(total), 0);
252
+ const netCents = order.netSubtotal ? toCents(order.netSubtotal) : itemsCents;
253
+ const discountCents = Math.max(0, itemsCents - netCents);
254
+ return {
255
+ ...toSummary(order),
256
+ lineItems: order.lines,
257
+ subtotal: itemsCents > 0 ? fromCents(itemsCents, currencyCode) : copyMoney(order.netSubtotal),
258
+ totalShipping: copyMoney(order.totalShipping),
259
+ totalTax: unlessZero(order.totalTax),
260
+ totalDiscount: discountCents > 0 ? fromCents(discountCents, currencyCode) : null,
261
+ totalRefunded: unlessZero(order.totalRefunded),
262
+ discountCodes: order.discountCodes,
263
+ };
264
+ }
265
+ // ── Reading ────────────────────────────────────────────────────────────────
266
+ /**
267
+ * Leeway for the phone's clock against Shopify's when telling a new order from the one before it: an
268
+ * order placed up to this long before `since` still counts (`useLatestOrderSince`). 2 minutes.
269
+ */
270
+ exports.ORDER_CLOCK_LEEWAY_MS = 2 * 60 * 1000;
271
+ /**
272
+ * Whether an order was placed at or after `since` (ms since 1970), less `clockLeewayMs`. Every order
273
+ * counts when `since` is null or undefined. An order whose date can't be read never counts.
274
+ */
275
+ function placedSince(order, since, clockLeewayMs = exports.ORDER_CLOCK_LEEWAY_MS) {
276
+ if (since == null)
277
+ return true;
278
+ return Date.parse(order.processedAt) >= since - clockLeewayMs;
279
+ }
280
+ const sessionEnded = () => new types_1.ShopifyError('The customer session has ended');
281
+ function toPage(raw, read) {
282
+ var _a, _b, _c, _d, _e;
283
+ return {
284
+ orders: ((_a = raw === null || raw === void 0 ? void 0 : raw.nodes) !== null && _a !== void 0 ? _a : []).filter((node) => !!node).map((node) => toSummary(read(node))),
285
+ endCursor: (_c = (_b = raw === null || raw === void 0 ? void 0 : raw.pageInfo) === null || _b === void 0 ? void 0 : _b.endCursor) !== null && _c !== void 0 ? _c : null,
286
+ hasNextPage: !!((_d = raw === null || raw === void 0 ? void 0 : raw.pageInfo) === null || _d === void 0 ? void 0 : _d.hasNextPage) && !!((_e = raw === null || raw === void 0 ? void 0 : raw.pageInfo) === null || _e === void 0 ? void 0 : _e.endCursor),
287
+ };
288
+ }
289
+ /** Shopify sign-in: the Customer Account API. */
290
+ function customerAccountOrders(accountRequest) {
291
+ return {
292
+ async list(first, after) {
293
+ var _a;
294
+ const data = await accountRequest(exports.ACCOUNT_ORDER_HISTORY_QUERY, { first, after });
295
+ return toPage((_a = data.customer) === null || _a === void 0 ? void 0 : _a.orders, fromAccount);
296
+ },
297
+ async get(id) {
298
+ const data = await accountRequest(exports.ACCOUNT_ORDER_DETAIL_QUERY, { id });
299
+ return data.order ? toDetails(fromAccount(data.order)) : null;
300
+ },
301
+ };
302
+ }
303
+ /**
304
+ * Email and password: the Storefront API, with the session's token. A token Shopify no longer accepts
305
+ * reads `customer: null`, which is the session ending, not an empty history.
306
+ */
307
+ function storefrontOrders(getAccessToken) {
308
+ async function token() {
309
+ const accessToken = await getAccessToken();
310
+ if (!accessToken)
311
+ throw sessionEnded();
312
+ return accessToken;
313
+ }
314
+ /** The cursor to read `id` after (null: it is the newest), or undefined when there is no such order. */
315
+ async function cursorBefore(accessToken, id) {
316
+ let after = null;
317
+ for (;;) {
318
+ const data = await (0, client_1.request)(exports.STOREFRONT_ORDER_IDS_QUERY, {
319
+ accessToken,
320
+ after,
321
+ });
322
+ if (!data.customer)
323
+ throw sessionEnded();
324
+ const { edges, pageInfo } = data.customer.orders;
325
+ const at = edges.findIndex((edge) => edge.node.id === id);
326
+ if (at >= 0)
327
+ return at === 0 ? after : edges[at - 1].cursor;
328
+ if (!pageInfo.hasNextPage || !pageInfo.endCursor)
329
+ return undefined;
330
+ after = pageInfo.endCursor;
331
+ }
332
+ }
333
+ return {
334
+ async list(first, after) {
335
+ const data = await (0, client_1.request)(exports.STOREFRONT_ORDER_HISTORY_QUERY, {
336
+ accessToken: await token(),
337
+ first,
338
+ after,
339
+ });
340
+ if (!data.customer)
341
+ throw sessionEnded();
342
+ return toPage(data.customer.orders, fromStorefront);
343
+ },
344
+ async get(id) {
345
+ const accessToken = await token();
346
+ // Twice at most: an order placed between the two reads moves the one asked for along by one.
347
+ for (let attempt = 0; attempt < 2; attempt += 1) {
348
+ const after = await cursorBefore(accessToken, id);
349
+ if (after === undefined)
350
+ return null;
351
+ const data = await (0, client_1.request)(exports.STOREFRONT_ORDER_DETAIL_QUERY, { accessToken, after });
352
+ if (!data.customer)
353
+ throw sessionEnded();
354
+ const node = data.customer.orders.nodes[0];
355
+ if ((node === null || node === void 0 ? void 0 : node.id) === id)
356
+ return toDetails(fromStorefront(node));
357
+ }
358
+ throw new types_1.ShopifyError('The order list changed while it was being read; try again');
359
+ },
360
+ };
361
+ }
362
+ /**
363
+ * A refreshed first page laid over what is on screen. The pages loaded after it are kept, so a list
364
+ * scrolled down stays where it was (they aren't re-read). When the fresh page doesn't reach back to
365
+ * them (many new orders since), or it is the whole history, it replaces the list.
366
+ */
367
+ function withFreshFirstPage(shown, page) {
368
+ const fresh = { orders: page.orders, endCursor: page.endCursor, hasMore: page.hasNextPage };
369
+ if (!page.hasNextPage || page.orders.length === 0)
370
+ return fresh;
371
+ const lastFresh = page.orders[page.orders.length - 1].id;
372
+ const at = shown.orders.findIndex((order) => order.id === lastFresh);
373
+ if (at < 0)
374
+ return fresh;
375
+ const freshIds = new Set(page.orders.map((order) => order.id));
376
+ const rest = shown.orders.slice(at + 1).filter((order) => !freshIds.has(order.id));
377
+ if (rest.length === 0)
378
+ return fresh;
379
+ return { orders: [...page.orders, ...rest], endCursor: shown.endCursor, hasMore: shown.hasMore };
380
+ }
381
+ /** The next page after what is shown, leaving out any order already there. */
382
+ function withNextPage(shown, page) {
383
+ const ids = new Set(shown.orders.map((order) => order.id));
384
+ return {
385
+ orders: [...shown.orders, ...page.orders.filter((order) => !ids.has(order.id))],
386
+ endCursor: page.endCursor,
387
+ hasMore: page.hasNextPage,
388
+ };
389
+ }
390
+ /**
391
+ * Which of an order's lines can go back in the cart, and how many of each, by the cart's stock rule
392
+ * (`stockCeiling`, as `useAddToCart` checks it): a quantity over what is left is cut to what is left,
393
+ * counting what the cart already holds and what earlier lines of this order take. `variants` are read
394
+ * fresh; a line whose variant isn't among them no longer exists.
395
+ *
396
+ * A variant still sold out and enrolled in pre-order (a selling plan) goes back on that plan, at the
397
+ * ordered quantity: a pre-order isn't limited by stock. Everything else goes back as an ordinary line.
398
+ * The same "sold out and on a plan" rule as the Waitlist's pre-order add. Decided 2026-10-04 by the
399
+ * Head of Engineering: "if item is still out of stock with selling plan add them as pre order
400
+ * otherwise add it normally".
401
+ *
402
+ * `options.skipVariant` leaves out (and counts as skipped) every line whose variant it returns true
403
+ * for, before anything is added or claimed. The app passes Cart Hold's `isHeldOut`, so a size whose
404
+ * every unit was just found held in other carts isn't tried again. Decided 2026-10-04 by the Head of
405
+ * Engineering.
406
+ */
407
+ function planBuyAgain(lines, variants, cart, options = {}) {
408
+ var _a, _b, _c, _d;
409
+ const byId = new Map(variants.map((variant) => [variant.id, variant]));
410
+ const planned = new Map();
411
+ const inputs = [];
412
+ let skipped = 0;
413
+ for (const line of lines) {
414
+ const variant = line.variantId ? byId.get(line.variantId) : undefined;
415
+ if (!variant || !variant.availableForSale || line.quantity <= 0) {
416
+ skipped += 1;
417
+ continue;
418
+ }
419
+ if ((_a = options.skipVariant) === null || _a === void 0 ? void 0 : _a.call(options, variant.id)) {
420
+ skipped += 1;
421
+ continue;
422
+ }
423
+ if (((_b = variant.quantityAvailable) !== null && _b !== void 0 ? _b : 0) <= 0 && variant.sellingPlan) {
424
+ inputs.push({ merchandiseId: variant.id, quantity: line.quantity, sellingPlanId: variant.sellingPlan.id });
425
+ continue;
426
+ }
427
+ const ceiling = (0, productPage_1.stockCeiling)(variant);
428
+ const taken = (0, productPage_1.quantityInCart)(cart, variant.id) + ((_c = planned.get(variant.id)) !== null && _c !== void 0 ? _c : 0);
429
+ const quantity = ceiling === null ? line.quantity : Math.min(line.quantity, ceiling - taken);
430
+ if (quantity <= 0) {
431
+ skipped += 1;
432
+ continue;
433
+ }
434
+ planned.set(variant.id, ((_d = planned.get(variant.id)) !== null && _d !== void 0 ? _d : 0) + quantity);
435
+ inputs.push({ merchandiseId: variant.id, quantity });
436
+ }
437
+ return { inputs,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Base } from './productStore';
2
+ import type { Cart, Money, Product, ProductMedia, ProductOption, ProductVariant } from './types';
3
+ /** What the page logic needs of a product: the full product, or the store's preview of it. */
4
+ export type ProductLike = ProductBase & Partial<Pick<Product, 'media' | 'onlineStoreUrl' | 'images'>>;
5
+ /** Chosen value per option name, e.g. `{ Size: 'SM', Color: 'Wine' }`. */
6
+ export type OptionSelection = Record<string, string>;
7
+ /** Selectors are shown Color, then Size, then anything else (case-insensitive). */
8
+ export declare const DEFAULT_OPTION_ORDER: readonly string[];
9
+ /**
10
+ * Shopify gives a single-variant product a placeholder option ("Title" with the one value "Default
11
+ * Title"). It is not a choice and must not become a selector.
12
+ */
13
+ export declare function isPlaceholderOption(option: ProductOption): boolean;
14
+ export interface SelectableOptionsConfig {
15
+ /** Option names in display order (case-insensitive); unlisted ones keep their order after these. */
16
+ order?: readonly string[];
17
+ /** Keep an option (default: everything but the placeholder). */
18
+ include?: (option: ProductOption) => boolean;
19
+ }
20
+ /** The options worth a selector, in display order. */
21
+ export declare function selectableOptions(options: ProductOption[] | null | undefined, config?: SelectableOptionsConfig): ProductOption[];
22
+ /** The variant matching every chosen value, or null for a combination Shopify doesn't sell. */
23
+ export declare function findVariant(variants: ProductVariant[] | null | undefined, selection: OptionSelection): ProductVariant | null;
24
+ /** The first purchasable combination, so Add to Cart works without touching a selector; else the first. */
25
+ export declare function initialSelection(variants: ProductVariant[] | null | undefined): OptionSelection;
26
+ /** The selection a variant represents, e.g. to preselect a variant from a link. */
27
+ export declare function selectionForVariant(variant: ProductVariant | null | undefined): OptionSelection;
28
+ /**
29
+ * Can't be bought now: no such combination, not for sale, or none left. A variant can be 0 left and
30
+ * still for sale (oversell / pre-order) only if `quantityAvailable` isn't 0, so 0 is treated as gone.
31
+ */
32
+ export declare function isVariantUnavailable(variant: ProductVariant | null | undefined): boolean;
33
+ export interface OptionValueState {
34
+ value: string;
35
+ selected: boolean;
36
+ /** The variant this value would select, keeping the other options as they are. */
37
+ variant: ProductVariant | null;
38
+ available: boolean;
39
+ /** Units left of that variant; null when Shopify doesn't track it. */
40
+ quantityAvailable: number | null;
41
+ }
42
+ export interface OptionState {
43
+ name: string;
44
+ selectedValue: string | null;
45
+ values: OptionValueState[];
46
+ }
47
+ /**
48
+ * Every value of every option with what choosing it would give. Stock is per combination, so a
49
+ * Size's count follows the selected Color and vice versa.
50
+ */
51
+ export declare function optionStates(options: ProductOption[], variants: ProductVariant[] | null | undefined, selection: OptionSelection, isUnavailable?: (variant: ProductVariant | null) => boolean): OptionState[];
52
+ /** "Ivory / L": the chosen values, in the options' order. */
53
+ export declare function selectionLabel(options: ProductOption[], selection: OptionSelection, separator?: string): string;
54
+ export interface VariantPrice {
55
+ price: Money | null;
56
+ /** Only when it is above `price`; Shopify returns "0.0" for "no compare-at". */
57
+ compareAtPrice: Money | null;
58
+ onSale: boolean;
59
+ }
60
+ /** The chosen variant's price; without a variant, the product's lowest. */
61
+ export declare function variantPrice(variant: ProductVariant | null | undefined, product?: Pick<ProductBase, 'priceRange' | 'compareAtPriceRange'> | null): VariantPrice;
62
+ /** "Hurry! Only a few pieces left." at or below this many units across the product. */
63
+ export declare const DEFAULT_LOW_STOCK_THRESHOLD = 10;
64
+ export declare function isLowStock(totalInventory: number | null | undefined, availableForSale: boolean | undefined, threshold?: number | null): boolean;
65
+ /**
66
+ * The most of `variant` a cart may hold, or null for no ceiling. Shopify doesn't refuse an add past
67
+ * the stock level (it answers 200 and clamps silently), so the ceiling is checked before the write.
68
+ * null: untracked inventory, or overselling allowed (`<= 0` while still for sale, e.g. pre-order).
69
+ */
70
+ export declare function stockCeiling(variant: Pick<ProductVariant, 'availableForSale' | 'quantityAvailable'> | null | undefined): number | null;
71
+ /** How many of `variantId` the cart holds, across every line (one variant can fill several). */
72
+ export declare function quantityInCart(cart: Pick<Cart, 'lines'> | null | undefined, variantId: string | null | undefined): number;
73
+ /** Whether `current + by` stays within `ceiling` (null: always). */
74
+ export declare function withinCeiling(ceiling: number | null, current: number, by?: number): boolean;
75
+ /** The gallery's opening slide: the first video when asked for (and there is one), else the first image. */
76
+ export declare function initialMediaIndex(media: ProductMedia[] | null | undefined, preferVideo?: boolean): number;
77
+ /** The first still, for a thumbnail. Videos sort first, so `media[0]` is often a video frame. */
78
+ export declare function firstImageUrl(product: Pick<ProductLike, 'media' | 'featuredImage'> | null | undefined): string | null;
79
+ export declare function sizedImageUrl(url: string | null | undefined, pixels: number): string | null;
80
+ export type DescriptionSpan = {
81
+ text: string;
82
+ bold: boolean;
83
+ };
84
+ /** A paragraph or a bullet. */
85
+ export type DescriptionBlock = {
86
+ spans: DescriptionSpan[];
87
+ bullet: boolean;
88
+ };
89
+ /**
90
+ * Shopify's `descriptionHtml` as paragraphs and bullets with their bold runs (the "Details:" /
91
+ * "Fit:" labels), for nested Text rather than an HTML renderer. Plain text works too.
92
+ */
93
+ export declare function parseDescriptionHtml(html: string | null | undefined): DescriptionBlock[];
94
+ /**
95
+ * The link to share: Shopify's `onlineStoreUrl` (a page a shopper can open), else
96
+ * `https://<storeDomain>/products/<handle>`, which on a store not on the Online Store channel is the
97
+ * myshopify host. `storeDomain` defaults to the configured one.
98
+ */
99
+ export declare function productShareUrl(product: Pick<ProductLike, 'handle' | 'onlineStoreUrl'> | null | undefined, storeDomain?: string): string | null;
100
+ //# sourceMappingURL=productPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productPage.d.ts","sourceRoot":"","sources":["../src/productPage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEjG,8FAA8F;AAC9F,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,CAAC,CAAC;AAEtG,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