@zappie/sdk 0.28.2 → 0.29.1

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 (364) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/account/index.d.ts +16 -2
  3. package/dist/account/index.js +0 -1
  4. package/dist/account/url.js +0 -1
  5. package/dist/branches/index.d.ts +2 -0
  6. package/dist/branches/index.js +0 -1
  7. package/dist/cart/branch.d.ts +18 -0
  8. package/dist/cart/branch.js +0 -1
  9. package/dist/cart/errors.js +0 -1
  10. package/dist/cart/held.js +0 -1
  11. package/dist/cart/index.js +1 -2
  12. package/dist/cart/item.d.ts +1 -1
  13. package/dist/cart/item.js +0 -1
  14. package/dist/cart/preview.js +0 -1
  15. package/dist/cart/price.js +0 -1
  16. package/dist/cart/quote-client.js +0 -1
  17. package/dist/cart/quote-response.js +1 -2
  18. package/dist/cart/quote.d.ts +1 -1
  19. package/dist/cart/reconcile.js +0 -1
  20. package/dist/cart/source-menu.js +0 -1
  21. package/dist/cart/storage.js +0 -1
  22. package/dist/cart/types.js +0 -1
  23. package/dist/cart/validate.js +0 -1
  24. package/dist/cart/wire.js +0 -1
  25. package/dist/cart/working-set.js +0 -1
  26. package/dist/checkout/client.js +0 -1
  27. package/dist/checkout/embed.d.ts +67 -2
  28. package/dist/checkout/embed.js +0 -1
  29. package/dist/checkout/error.js +0 -1
  30. package/dist/checkout/index.d.ts +74 -3
  31. package/dist/checkout/index.js +0 -1
  32. package/dist/checkout/react.d.ts +67 -2
  33. package/dist/checkout/react.js +0 -1
  34. package/dist/checkout/readiness.js +0 -1
  35. package/dist/checkout/sdk.js +0 -1
  36. package/dist/checkout/session.js +0 -1
  37. package/dist/checkout/types.js +0 -1
  38. package/dist/checkout-defaults/index.d.ts +10 -1
  39. package/dist/checkout-defaults/index.js +0 -1
  40. package/dist/{client-B89-aNcl.d.ts → client-CW_OWZ0l.d.ts} +229 -5
  41. package/dist/client.js +0 -1
  42. package/dist/config/index.d.ts +38 -3
  43. package/dist/config/index.js +0 -1
  44. package/dist/config.js +0 -1
  45. package/dist/customer/client.js +0 -1
  46. package/dist/customer/error.js +0 -1
  47. package/dist/customer/index.d.ts +180 -5
  48. package/dist/customer/index.js +0 -1
  49. package/dist/customer/navigation.js +0 -1
  50. package/dist/customer/react.js +0 -1
  51. package/dist/customer/reorder.d.ts +8 -0
  52. package/dist/customer/reorder.js +0 -1
  53. package/dist/customer/request.js +0 -1
  54. package/dist/customer/types.js +0 -1
  55. package/dist/customer/watch-order.js +0 -1
  56. package/dist/debug.js +1 -2
  57. package/dist/display/index.d.ts +5 -1
  58. package/dist/display/index.js +0 -1
  59. package/dist/error-pages/art.js +0 -1
  60. package/dist/error-pages/index.d.ts +12 -1
  61. package/dist/error-pages/index.js +0 -1
  62. package/dist/error-pages/react.js +0 -1
  63. package/dist/errors.js +1 -2
  64. package/dist/in-venue/bill.js +0 -1
  65. package/dist/in-venue/client.js +0 -1
  66. package/dist/in-venue/error.js +0 -1
  67. package/dist/in-venue/index.d.ts +110 -2
  68. package/dist/in-venue/index.js +0 -1
  69. package/dist/in-venue/react/bill-page.js +0 -1
  70. package/dist/in-venue/react/in-venue-page.js +0 -1
  71. package/dist/in-venue/react/order-panel.js +0 -1
  72. package/dist/in-venue/react/pay-point-page.js +0 -1
  73. package/dist/in-venue/react/shared.js +0 -1
  74. package/dist/in-venue/react/table-menus-page.js +0 -1
  75. package/dist/in-venue/react.js +0 -1
  76. package/dist/in-venue/table.js +0 -1
  77. package/dist/in-venue/types.js +0 -1
  78. package/dist/in-venue/watch.js +0 -1
  79. package/dist/index.d.ts +32 -8
  80. package/dist/index.js +1 -2
  81. package/dist/integrations/index.d.ts +15 -2
  82. package/dist/integrations/index.js +0 -1
  83. package/dist/internal/abort.js +0 -1
  84. package/dist/internal/cache.js +0 -1
  85. package/dist/internal/customer-http.js +1 -2
  86. package/dist/internal/emitter.js +0 -1
  87. package/dist/internal/image-widths.js +0 -1
  88. package/dist/internal/money-math.js +0 -1
  89. package/dist/internal/perk-hold.js +0 -1
  90. package/dist/internal/remembered-address.js +0 -1
  91. package/dist/internal/return-path.js +0 -1
  92. package/dist/internal/service-url.js +0 -1
  93. package/dist/internal.d.ts +2 -2
  94. package/dist/internal.js +0 -1
  95. package/dist/loyalty/cart.js +0 -1
  96. package/dist/loyalty/client.js +0 -1
  97. package/dist/loyalty/index.d.ts +410 -2
  98. package/dist/loyalty/index.js +0 -1
  99. package/dist/loyalty/react.d.ts +15 -1
  100. package/dist/loyalty/react.js +0 -1
  101. package/dist/loyalty/release.js +0 -1
  102. package/dist/loyalty/types.js +0 -1
  103. package/dist/menu/index.d.ts +5 -1
  104. package/dist/menu/index.js +0 -1
  105. package/dist/models-C77LjkK8.d.ts +540 -0
  106. package/dist/models.js +0 -1
  107. package/dist/money.js +0 -1
  108. package/dist/navigation/index.d.ts +8 -0
  109. package/dist/navigation/index.js +0 -1
  110. package/dist/navigation/react.js +0 -1
  111. package/dist/navigation-progress/index.js +0 -1
  112. package/dist/options/index.d.ts +5 -1
  113. package/dist/options/index.js +0 -1
  114. package/dist/persist/catalogue.d.ts +3 -3
  115. package/dist/persist/catalogue.js +0 -1
  116. package/dist/places/client.js +0 -1
  117. package/dist/places/error.js +0 -1
  118. package/dist/places/index.d.ts +41 -1
  119. package/dist/places/index.js +0 -1
  120. package/dist/places/request.js +0 -1
  121. package/dist/places/sdk.js +0 -1
  122. package/dist/places/search.js +0 -1
  123. package/dist/places/types.js +0 -1
  124. package/dist/pricing/index.js +0 -1
  125. package/dist/react/cart.js +0 -1
  126. package/dist/react/changes.js +0 -1
  127. package/dist/react/hooks.js +0 -1
  128. package/dist/react/index.js +0 -1
  129. package/dist/react/provider.js +0 -1
  130. package/dist/react/rollback.js +0 -1
  131. package/dist/receipts/index.js +1 -2
  132. package/dist/redirect/index.js +0 -1
  133. package/dist/rich-text/index.d.ts +4 -0
  134. package/dist/rich-text/index.js +0 -1
  135. package/dist/server/auth/crypto.js +0 -1
  136. package/dist/server/auth/jwt.js +0 -1
  137. package/dist/server/auth/session-store.js +0 -1
  138. package/dist/server/chosen-branch.js +0 -1
  139. package/dist/server/edge-cache.js +0 -1
  140. package/dist/server/edge-snapshot.js +0 -1
  141. package/dist/server/index.d.ts +179 -8
  142. package/dist/server/index.js +0 -1
  143. package/dist/server/legacy-order.js +0 -1
  144. package/dist/server/page-cache.js +0 -1
  145. package/dist/server/security.js +0 -1
  146. package/dist/server/sign-in.js +0 -1
  147. package/dist/server/site-seo.js +0 -1
  148. package/dist/server/site-worker.js +0 -1
  149. package/dist/server/storefront-url/build-v1.js +0 -1
  150. package/dist/server/storefront-url/build-v2.js +0 -1
  151. package/dist/server/storefront-url/build.js +0 -1
  152. package/dist/server/storefront-url/canonical.js +0 -1
  153. package/dist/server/storefront-url/contract.js +0 -1
  154. package/dist/server/storefront-url/index.js +0 -1
  155. package/dist/server/storefront-url/installation.js +0 -1
  156. package/dist/server/storefront-url/params.js +0 -1
  157. package/dist/server/storefront-url/parse-v1.js +0 -1
  158. package/dist/server/storefront-url/parse-v2.js +0 -1
  159. package/dist/server/storefront-url/parse.js +0 -1
  160. package/dist/server/storefront-url/public-id.js +0 -1
  161. package/dist/server/storefront-url/redirect.js +0 -1
  162. package/dist/server/storefront-url/sign-in.js +0 -1
  163. package/dist/server/storefront-url/types.js +0 -1
  164. package/dist/server/storefront-url/url.js +0 -1
  165. package/dist/server/webhook.js +0 -1
  166. package/dist/services/index.d.ts +5 -1
  167. package/dist/services/index.js +0 -1
  168. package/dist/site-closed/index.d.ts +3 -0
  169. package/dist/site-closed/index.js +0 -1
  170. package/dist/site-config/helpers.js +0 -1
  171. package/dist/site-config/sections.js +0 -1
  172. package/dist/site-config/types.js +0 -1
  173. package/dist/site-config/validate.js +0 -1
  174. package/dist/site-error/index.d.ts +9 -1
  175. package/dist/site-error/index.js +0 -1
  176. package/dist/site-error/react.js +0 -1
  177. package/dist/studio/index.d.ts +2 -0
  178. package/dist/template/index.d.ts +7 -1
  179. package/dist/template/index.js +0 -1
  180. package/dist/template/react.js +0 -1
  181. package/dist/testing/index.d.ts +28 -1
  182. package/dist/testing/index.js +1 -1
  183. package/dist/testing/loyalty.js +0 -1
  184. package/dist/transport/category-page.js +0 -1
  185. package/dist/transport/mappers.js +0 -1
  186. package/dist/transport/presentation.js +0 -1
  187. package/dist/transport/quote-body.js +0 -1
  188. package/dist/transport/rest.js +0 -1
  189. package/dist/transport/search.d.ts +1 -1
  190. package/dist/transport/search.js +0 -1
  191. package/dist/transport/selected-menu.d.ts +3 -3
  192. package/dist/transport/selected-menu.js +0 -1
  193. package/dist/transport/store.js +0 -1
  194. package/dist/transport/types.js +0 -1
  195. package/dist/types-CuPaBf6k.d.ts +838 -0
  196. package/dist/uploads/index.js +0 -1
  197. package/dist/url/index.d.ts +31 -0
  198. package/dist/url/index.js +0 -1
  199. package/dist/visits/index.d.ts +26 -1
  200. package/dist/visits/index.js +0 -1
  201. package/dist/visits/page-views.js +0 -1
  202. package/dist/vite/index.d.ts +2 -0
  203. package/package.json +2 -2
  204. package/dist/account/index.js.map +0 -6
  205. package/dist/account/url.js.map +0 -6
  206. package/dist/branches/index.js.map +0 -6
  207. package/dist/cart/branch.js.map +0 -6
  208. package/dist/cart/errors.js.map +0 -6
  209. package/dist/cart/held.js.map +0 -6
  210. package/dist/cart/index.js.map +0 -6
  211. package/dist/cart/item.js.map +0 -6
  212. package/dist/cart/preview.js.map +0 -6
  213. package/dist/cart/price.js.map +0 -6
  214. package/dist/cart/quote-client.js.map +0 -6
  215. package/dist/cart/quote-response.js.map +0 -6
  216. package/dist/cart/reconcile.js.map +0 -6
  217. package/dist/cart/source-menu.js.map +0 -6
  218. package/dist/cart/storage.js.map +0 -6
  219. package/dist/cart/types.js.map +0 -6
  220. package/dist/cart/validate.js.map +0 -6
  221. package/dist/cart/wire.js.map +0 -6
  222. package/dist/cart/working-set.js.map +0 -6
  223. package/dist/checkout/client.js.map +0 -6
  224. package/dist/checkout/embed.js.map +0 -6
  225. package/dist/checkout/error.js.map +0 -6
  226. package/dist/checkout/index.js.map +0 -6
  227. package/dist/checkout/react.js.map +0 -6
  228. package/dist/checkout/readiness.js.map +0 -6
  229. package/dist/checkout/sdk.js.map +0 -6
  230. package/dist/checkout/session.js.map +0 -6
  231. package/dist/checkout/types.js.map +0 -6
  232. package/dist/checkout-defaults/index.js.map +0 -6
  233. package/dist/client.js.map +0 -6
  234. package/dist/config/index.js.map +0 -6
  235. package/dist/config.js.map +0 -6
  236. package/dist/customer/client.js.map +0 -6
  237. package/dist/customer/error.js.map +0 -6
  238. package/dist/customer/index.js.map +0 -6
  239. package/dist/customer/navigation.js.map +0 -6
  240. package/dist/customer/react.js.map +0 -6
  241. package/dist/customer/reorder.js.map +0 -6
  242. package/dist/customer/request.js.map +0 -6
  243. package/dist/customer/types.js.map +0 -6
  244. package/dist/customer/watch-order.js.map +0 -6
  245. package/dist/debug.js.map +0 -6
  246. package/dist/display/index.js.map +0 -6
  247. package/dist/error-pages/art.js.map +0 -6
  248. package/dist/error-pages/index.js.map +0 -6
  249. package/dist/error-pages/react.js.map +0 -6
  250. package/dist/errors.js.map +0 -6
  251. package/dist/in-venue/bill.js.map +0 -6
  252. package/dist/in-venue/client.js.map +0 -6
  253. package/dist/in-venue/error.js.map +0 -6
  254. package/dist/in-venue/index.js.map +0 -6
  255. package/dist/in-venue/react/bill-page.js.map +0 -6
  256. package/dist/in-venue/react/in-venue-page.js.map +0 -6
  257. package/dist/in-venue/react/order-panel.js.map +0 -6
  258. package/dist/in-venue/react/pay-point-page.js.map +0 -6
  259. package/dist/in-venue/react/shared.js.map +0 -6
  260. package/dist/in-venue/react/table-menus-page.js.map +0 -6
  261. package/dist/in-venue/react.js.map +0 -6
  262. package/dist/in-venue/table.js.map +0 -6
  263. package/dist/in-venue/types.js.map +0 -6
  264. package/dist/in-venue/watch.js.map +0 -6
  265. package/dist/index.js.map +0 -6
  266. package/dist/integrations/index.js.map +0 -6
  267. package/dist/internal/abort.js.map +0 -6
  268. package/dist/internal/cache.js.map +0 -6
  269. package/dist/internal/customer-http.js.map +0 -6
  270. package/dist/internal/emitter.js.map +0 -6
  271. package/dist/internal/image-widths.js.map +0 -6
  272. package/dist/internal/money-math.js.map +0 -6
  273. package/dist/internal/perk-hold.js.map +0 -6
  274. package/dist/internal/remembered-address.js.map +0 -6
  275. package/dist/internal/return-path.js.map +0 -6
  276. package/dist/internal/service-url.js.map +0 -6
  277. package/dist/internal.js.map +0 -6
  278. package/dist/loyalty/cart.js.map +0 -6
  279. package/dist/loyalty/client.js.map +0 -6
  280. package/dist/loyalty/index.js.map +0 -6
  281. package/dist/loyalty/react.js.map +0 -6
  282. package/dist/loyalty/release.js.map +0 -6
  283. package/dist/loyalty/types.js.map +0 -6
  284. package/dist/menu/index.js.map +0 -6
  285. package/dist/models-DLGs3UI2.d.ts +0 -307
  286. package/dist/models.js.map +0 -6
  287. package/dist/money.js.map +0 -6
  288. package/dist/navigation/index.js.map +0 -6
  289. package/dist/navigation/react.js.map +0 -6
  290. package/dist/navigation-progress/index.js.map +0 -6
  291. package/dist/options/index.js.map +0 -6
  292. package/dist/persist/catalogue.js.map +0 -6
  293. package/dist/places/client.js.map +0 -6
  294. package/dist/places/error.js.map +0 -6
  295. package/dist/places/index.js.map +0 -6
  296. package/dist/places/request.js.map +0 -6
  297. package/dist/places/sdk.js.map +0 -6
  298. package/dist/places/search.js.map +0 -6
  299. package/dist/places/types.js.map +0 -6
  300. package/dist/pricing/index.js.map +0 -6
  301. package/dist/react/cart.js.map +0 -6
  302. package/dist/react/changes.js.map +0 -6
  303. package/dist/react/hooks.js.map +0 -6
  304. package/dist/react/index.js.map +0 -6
  305. package/dist/react/provider.js.map +0 -6
  306. package/dist/react/rollback.js.map +0 -6
  307. package/dist/receipts/index.js.map +0 -6
  308. package/dist/redirect/index.js.map +0 -6
  309. package/dist/rich-text/index.js.map +0 -6
  310. package/dist/server/auth/crypto.js.map +0 -6
  311. package/dist/server/auth/jwt.js.map +0 -6
  312. package/dist/server/auth/session-store.js.map +0 -6
  313. package/dist/server/chosen-branch.js.map +0 -6
  314. package/dist/server/edge-cache.js.map +0 -6
  315. package/dist/server/edge-snapshot.js.map +0 -6
  316. package/dist/server/index.js.map +0 -6
  317. package/dist/server/legacy-order.js.map +0 -6
  318. package/dist/server/page-cache.js.map +0 -6
  319. package/dist/server/security.js.map +0 -6
  320. package/dist/server/sign-in.js.map +0 -6
  321. package/dist/server/site-seo.js.map +0 -6
  322. package/dist/server/site-worker.js.map +0 -6
  323. package/dist/server/storefront-url/build-v1.js.map +0 -6
  324. package/dist/server/storefront-url/build-v2.js.map +0 -6
  325. package/dist/server/storefront-url/build.js.map +0 -6
  326. package/dist/server/storefront-url/canonical.js.map +0 -6
  327. package/dist/server/storefront-url/contract.js.map +0 -6
  328. package/dist/server/storefront-url/index.js.map +0 -6
  329. package/dist/server/storefront-url/installation.js.map +0 -6
  330. package/dist/server/storefront-url/params.js.map +0 -6
  331. package/dist/server/storefront-url/parse-v1.js.map +0 -6
  332. package/dist/server/storefront-url/parse-v2.js.map +0 -6
  333. package/dist/server/storefront-url/parse.js.map +0 -6
  334. package/dist/server/storefront-url/public-id.js.map +0 -6
  335. package/dist/server/storefront-url/redirect.js.map +0 -6
  336. package/dist/server/storefront-url/sign-in.js.map +0 -6
  337. package/dist/server/storefront-url/types.js.map +0 -6
  338. package/dist/server/storefront-url/url.js.map +0 -6
  339. package/dist/server/webhook.js.map +0 -6
  340. package/dist/services/index.js.map +0 -6
  341. package/dist/site-closed/index.js.map +0 -6
  342. package/dist/site-config/helpers.js.map +0 -6
  343. package/dist/site-config/sections.js.map +0 -6
  344. package/dist/site-config/types.js.map +0 -6
  345. package/dist/site-config/validate.js.map +0 -6
  346. package/dist/site-error/index.js.map +0 -6
  347. package/dist/site-error/react.js.map +0 -6
  348. package/dist/template/index.js.map +0 -6
  349. package/dist/template/react.js.map +0 -6
  350. package/dist/testing/loyalty.js.map +0 -6
  351. package/dist/transport/category-page.js.map +0 -6
  352. package/dist/transport/mappers.js.map +0 -6
  353. package/dist/transport/presentation.js.map +0 -6
  354. package/dist/transport/quote-body.js.map +0 -6
  355. package/dist/transport/rest.js.map +0 -6
  356. package/dist/transport/search.js.map +0 -6
  357. package/dist/transport/selected-menu.js.map +0 -6
  358. package/dist/transport/store.js.map +0 -6
  359. package/dist/transport/types.js.map +0 -6
  360. package/dist/types-8HB4-7D9.d.ts +0 -457
  361. package/dist/uploads/index.js.map +0 -6
  362. package/dist/url/index.js.map +0 -6
  363. package/dist/visits/index.js.map +0 -6
  364. package/dist/visits/page-views.js.map +0 -6
@@ -0,0 +1,838 @@
1
+ import { f as Currency, M as Money, I as Item } from './models-C77LjkK8.js';
2
+
3
+ /**
4
+ * An item selection you submit to the cart, with optional quantity, choices, inputs and source menu.
5
+ */
6
+ type CartLineInput = {
7
+ /** The item's ID. */
8
+ itemId: string;
9
+ /**
10
+ * The source menu the shopper selected. The SDK checks catalogue membership. Without one, the
11
+ * cart files the line under its default menu, `withDefaultMenu`.
12
+ */
13
+ menuId?: string;
14
+ /**
15
+ * How many units of the item. Defaults to the item's minimum quantity. It must be a whole
16
+ * number within the item's limits and step, and 99 at most.
17
+ */
18
+ quantity?: number;
19
+ /**
20
+ * The choices the shopper picked, each by its option group ID and choice ID. A choice's
21
+ * `quantity` is how many units of it, and defaults to 1. Choices in an unavailable group are
22
+ * dropped.
23
+ */
24
+ choices?: {
25
+ groupId: string;
26
+ choiceId: string;
27
+ quantity?: number;
28
+ }[];
29
+ /**
30
+ * What the shopper typed for the item's input groups (text, number, date, time or toggle),
31
+ * keyed by group ID. A date is `YYYY-MM-DD`, a time is `HH:MM` or `HH:MM:SS`, and a toggle is
32
+ * `true` or `false`. A saved cart left alone for more than 24 hours loses its inputs.
33
+ */
34
+ inputs?: Record<string, string>;
35
+ /**
36
+ * The exact variant. When you leave it out, the cart picks the one variant that matches the
37
+ * attribute choices in `choices`. A variant that doesn't match them is refused.
38
+ */
39
+ variantId?: string;
40
+ /** The shopper's note for this line, 280 characters at most. It goes on the order. */
41
+ note?: string;
42
+ };
43
+ /**
44
+ * A readonly cart line with its selection, local price estimate and time added.
45
+ */
46
+ type CartLine = Readonly<{
47
+ id: string;
48
+ itemId: string;
49
+ /** The source menu the shopper selected. The SDK checks catalogue membership. */
50
+ menuId?: string;
51
+ name: string;
52
+ quantity: number;
53
+ choices: readonly Readonly<{
54
+ groupId: string;
55
+ choiceId: string;
56
+ quantity: number;
57
+ }>[];
58
+ inputs: Readonly<Record<string, string>>;
59
+ variantId?: string;
60
+ note?: string;
61
+ unitPrice: Money;
62
+ lineSubtotal: Money;
63
+ addedAt: string;
64
+ }>;
65
+ /**
66
+ * A cart delivery address with optional place coordinates and instructions.
67
+ */
68
+ type DeliveryAddress = {
69
+ /** The first line of the address, such as the street and number. It can't be blank. */
70
+ line1: string;
71
+ /**
72
+ * A second address line. The cart keeps it, but the API doesn't take it, so quotes and checkout
73
+ * leave it out.
74
+ */
75
+ line2?: string;
76
+ /** The city. */
77
+ city?: string;
78
+ /** A place ID from the places lookup. The quote prices delivery to that place. */
79
+ placeId?: string;
80
+ /** The address's latitude and longitude in degrees. */
81
+ coordinates?: {
82
+ lat: number;
83
+ lng: number;
84
+ };
85
+ /** Instructions for the rider or the counter. Pricing ignores them. */
86
+ instructions?: string;
87
+ };
88
+ /** A shopper's selection, distinct from the store's Fulfilment capabilities. */
89
+ type CartFulfilment = {
90
+ type: "pickup";
91
+ branchId: string;
92
+ scheduledFor?: string;
93
+ } | {
94
+ type: "delivery";
95
+ branchId: string;
96
+ address: DeliveryAddress;
97
+ /** The delivery region you selected from the branch. */
98
+ deliveryRegionId?: string;
99
+ scheduledFor?: string;
100
+ } | {
101
+ type: "dine_in";
102
+ branchId: string;
103
+ table?: string;
104
+ /** The table the guest scanned. It stays with the saved cart. Quotes price the cart at its branch. */
105
+ payPointId?: string;
106
+ };
107
+ /**
108
+ * Delivery the shopper chose before giving its address, with the time it starts on. The cart can't
109
+ * hold a delivery without an address, so while it holds no fulfilment, quotes price this instead:
110
+ * the bag shows the total and taxes for delivery at that time, and the quote asks for the
111
+ * address. It is never sent to checkout.
112
+ */
113
+ type PendingFulfilment = {
114
+ /** Always `delivery`. Pickup and dine-in need no address, so you set them with `setFulfilment`. */
115
+ type: "delivery";
116
+ /**
117
+ * When the order is for, as an RFC 3339 date and time. Left out for as soon as possible.
118
+ */
119
+ scheduledFor?: string | undefined;
120
+ };
121
+ /**
122
+ * Stable identifiers for cart validation and quote issues you can handle in your UI.
123
+ */
124
+ type CartIssueCode =
125
+ /**
126
+ * The item, its variant or its menu can't be ordered now. The cart raises it when the item is
127
+ * missing from its catalogue, is unavailable, or no menu at the branch lists it, and as a warning
128
+ * from `moveTo` for each line the new branch can't sell. A blocking quote issue whose code is
129
+ * newer than this SDK also arrives as this code, with the API's code in `data.code`.
130
+ */
131
+ "item_unavailable"
132
+ /**
133
+ * The item isn't on the branch's menus. The cart raises it when `update` names a line ID the
134
+ * cart doesn't hold.
135
+ */
136
+ | "item_not_found"
137
+ /**
138
+ * A picked choice is unavailable. The cart also raises it for a choice or input whose option
139
+ * group no longer exists.
140
+ */
141
+ | "option_unavailable"
142
+ /**
143
+ * A required option group has no pick, or an item with attributes has no variant. The cart
144
+ * raises it for a required group with no choice and no typed answer.
145
+ */
146
+ | "option_required"
147
+ /**
148
+ * The picks break a group's rules, such as too many units or a choice from another group. The
149
+ * cart also raises it for a note over 280 characters, a group given both a choice and a typed
150
+ * answer, an answer in the wrong format, a choice quantity out of range, and choices that match
151
+ * no available variant.
152
+ */
153
+ | "option_limit"
154
+ /**
155
+ * The quantity is outside the item's limits. From the quote, `data.quantity` is the nearest
156
+ * allowed. The cart raises it for a quantity that isn't a whole number in the item's range and
157
+ * step, with a `set_quantity` fix, and when an add would take the cart past 100 lines.
158
+ */
159
+ | "quantity_limit"
160
+ /**
161
+ * A line's price changed. The quote raises it when the price differs from the one at the
162
+ * request's `menu_version`. The cart raises it as a warning when a saved or refreshed line's
163
+ * estimate differs from the price it held. Both give `data.previous` and `data.current`.
164
+ */
165
+ | "price_changed"
166
+ /**
167
+ * The branch is closed now. `data.next_open_at` says when it opens again. It is `info` for a
168
+ * scheduled cart. Only the quote raises it.
169
+ */
170
+ | "branch_closed"
171
+ /**
172
+ * The branch doesn't take this fulfilment mode, and `data.offered` lists the modes it does. The
173
+ * cart raises it when `setFulfilment` gets an invalid selection or one for another branch, and
174
+ * when `toCheckoutPayload` runs with no lines or no fulfilment.
175
+ */
176
+ | "fulfilment_unavailable"
177
+ /**
178
+ * The branch doesn't deliver to the address. `data.reason` is `outside_zone`, or
179
+ * `address_unresolved` when the address could not be found. Only the quote raises it.
180
+ */
181
+ | "outside_delivery_zone"
182
+ /**
183
+ * The shopper must pick one of the branch's delivery regions, then you set it as
184
+ * `deliveryRegionId`. Only the quote raises it.
185
+ */
186
+ | "delivery_region_required"
187
+ /**
188
+ * The scheduled time is in the past or too soon for the menu's notice. Only the quote raises it.
189
+ */
190
+ | "schedule_invalid"
191
+ /**
192
+ * The promo code doesn't apply, with the code in `data.promo_code`. A warning. Only the quote
193
+ * raises it.
194
+ */
195
+ | "promo_invalid"
196
+ /** The cart is below the promo code's minimum spend. A warning. Only the quote raises it. */
197
+ | "promo_min_spend"
198
+ /** Reserved. The API doesn't send it today. */
199
+ | "min_order"
200
+ /**
201
+ * The menus changed since the request's `menu_version`, and `data.menu_version` is the current
202
+ * one. An `info` issue. The cart refreshes its menu when it sees it. Only the quote raises it.
203
+ */
204
+ | "menu_version_stale"
205
+ /**
206
+ * A perk redemption can't be used on this order, because it was cancelled, used or reserved at
207
+ * another branch. The quote is then priced without the perks. Only the quote raises it.
208
+ */
209
+ | "perk_invalid"
210
+ /**
211
+ * A checkout field the store asks for is missing. `data.field` names the field. It comes only for a
212
+ * signed-in customer, and only from the quote.
213
+ */
214
+ | "checkout_field_required"
215
+ /**
216
+ * A checkout field's value can't be used. `data.field` names the field and `data.reason` is
217
+ * `format`, or `taken` when the email is on another account. It comes only for a signed-in
218
+ * customer, and only from the quote.
219
+ */
220
+ | "checkout_field_invalid";
221
+ /**
222
+ * A suggested cart correction, including any option, quantity or fulfilment details it needs.
223
+ */
224
+ type CartFix = {
225
+ /**
226
+ * What to offer the shopper. `remove_line` takes the issue's line out, and `applyFix` does
227
+ * it. `accept_price` keeps the line at its new price, and `applyFix` clears the issue.
228
+ * `remove_promo` drops the promo code, and `applyFix` does it. `change_address` asks for
229
+ * another address, which you set with `setFulfilment`. `choose_region` asks the shopper to
230
+ * pick a delivery region, which you set as `deliveryRegionId` with `setFulfilment`.
231
+ * `remove_perks` drops the perk redemptions, and `applyFix` does it.
232
+ */
233
+ action: "remove_line" | "accept_price" | "remove_promo" | "change_address" | "choose_region" | "remove_perks";
234
+ } | {
235
+ /**
236
+ * `choose_option` asks the shopper to pick in the group. `choose_other_option` asks for
237
+ * another choice in the group, because the picked one is unavailable. Apply either with
238
+ * `update`.
239
+ */
240
+ action: "choose_option" | "choose_other_option";
241
+ /** The option group to pick in. */
242
+ groupId: string;
243
+ } | {
244
+ /** `set_quantity` changes the line's quantity to `quantity`, and `applyFix` does it. */
245
+ action: "set_quantity";
246
+ /** The nearest quantity the item allows, from 1 to 99. */
247
+ quantity: number;
248
+ } | {
249
+ /**
250
+ * `schedule` asks the shopper to schedule the order, for `nextOpenAt` or later. Set the time
251
+ * with `setFulfilment`.
252
+ */
253
+ action: "schedule";
254
+ /**
255
+ * When the branch or the menu opens next, as an RFC 3339 date and time in UTC. Left out
256
+ * when the API sends none.
257
+ */
258
+ nextOpenAt?: string;
259
+ /** Reserved for times the shopper can choose. The API doesn't send it today. */
260
+ slots?: string[];
261
+ } | {
262
+ /** `switch_fulfilment` asks the shopper to change to one of the modes in `types`. */
263
+ action: "switch_fulfilment";
264
+ /** The fulfilment modes the branch offers. The SDK drops modes it doesn't know. */
265
+ types: CartFulfilment["type"][];
266
+ } | {
267
+ /**
268
+ * `fill_field` asks the shopper for the checkout field in `field`, on a
269
+ * `checkout_field_required` or `checkout_field_invalid` issue. Ask for it in your checkout
270
+ * form. `applyFix` can't fill it in.
271
+ */
272
+ action: "fill_field";
273
+ /** The checkout field's key, such as `email` or a key from `Quote.checkout.fields`. */
274
+ field: string;
275
+ };
276
+ /**
277
+ * What the shopper typed for the store's built-in checkout fields, with API field names. A detail
278
+ * the signed-in customer's account already holds is used instead.
279
+ */
280
+ type CheckoutCustomer = {
281
+ /** The shopper's first name, 100 characters at most. */
282
+ given_name?: string;
283
+ /** The shopper's last name, 100 characters at most. */
284
+ family_name?: string;
285
+ /**
286
+ * The shopper's email, 254 characters at most. An email on another account comes back as
287
+ * `checkout_field_invalid` with `data.reason` `taken`.
288
+ */
289
+ email?: string;
290
+ };
291
+ /**
292
+ * A local or quoted cart issue with severity, display message and suggested fixes.
293
+ */
294
+ type CartIssue = {
295
+ /** What the problem is. Each code says when it is raised and what goes in `data`. */
296
+ code: CartIssueCode;
297
+ /**
298
+ * How much the issue matters. `blocking` stops checkout until the shopper fixes it. Every issue
299
+ * the cart raises itself is `blocking`, except `price_changed` and the lines `moveTo` drops.
300
+ * `warning` tells the shopper something changed, and checkout still goes through. `info` is a
301
+ * notice only, and leaves the cart state `quoted`.
302
+ */
303
+ severity: "blocking" | "warning" | "info";
304
+ /** The cart line the issue is about. Left out for an issue with the whole cart. */
305
+ lineId?: string;
306
+ /**
307
+ * The option group the issue is about. The cart's own checks set it, and a quote issue takes it
308
+ * from the API's `data.group_id`, so the cart shows a problem both report once. Left out for an
309
+ * issue with no group.
310
+ */
311
+ groupId?: string;
312
+ /** A message you can show the shopper. */
313
+ message: string;
314
+ /**
315
+ * Details that depend on the code, listed with each `CartIssueCode`. From the quote, it holds
316
+ * the API's details as sent, in snake_case with money as `amount_minor` and `currency`. Left out
317
+ * when there are none.
318
+ */
319
+ data?: Record<string, unknown>;
320
+ /**
321
+ * Ways to resolve the issue, in the order to offer them. It can be empty. Pass one to
322
+ * `applyFix`.
323
+ */
324
+ fixes: CartFix[];
325
+ /**
326
+ * Where the issue comes from. `local` means the cart's own checks against the menu it holds
327
+ * found it. `quote` means the API's quote reported it.
328
+ */
329
+ source: "local" | "quote";
330
+ };
331
+ /**
332
+ * Server-provided cart pricing, fees, discounts, issues and checkout readiness with an expiry.
333
+ */
334
+ type Quote = {
335
+ /** Null prices mean the service could not split the subtotal across lines. */
336
+ lines: {
337
+ lineId: string;
338
+ unitPrice: Money | null;
339
+ total: Money | null;
340
+ /** Item identity echoed by the quote. */
341
+ itemId?: string;
342
+ /** Item name returned by the quote. */
343
+ name?: string;
344
+ /** Quantity priced by the quote. */
345
+ quantity?: number;
346
+ /** Authoritative option total, or null when the line could not be priced. */
347
+ optionsTotal?: Money | null;
348
+ /** Line status returned by the service. */
349
+ status?: string;
350
+ }[];
351
+ /** Whether the submitted menu version differs from the current version. */
352
+ menuVersionStale?: boolean;
353
+ /** Fulfilment details and arrival estimate returned by the service. */
354
+ fulfilment?: {
355
+ type: string;
356
+ scheduledFor: string | null;
357
+ etaMinutes?: number[];
358
+ deliveryRegionId?: string;
359
+ };
360
+ /**
361
+ * True when you can't trust the per-line prices, which can then be null. The overall totals
362
+ * still hold. Left out otherwise.
363
+ */
364
+ linesUnpriced?: boolean;
365
+ /** What the lines cost before charges and discounts. A line with status `invalid` isn't in it. */
366
+ subtotal: Money;
367
+ /**
368
+ * The charges on top of the subtotal other than delivery, such as a service charge, packaging
369
+ * or VAT. `code` says what each is for and `label` is the business's own name for it. A charge
370
+ * at zero is left out.
371
+ */
372
+ fees: {
373
+ code: string;
374
+ label: string;
375
+ amount: Money;
376
+ }[];
377
+ /** The sum of `fees`, so you can show one fees line. Zero when there are none. Delivery is not included. */
378
+ feesTotal: Money;
379
+ /**
380
+ * The delivery fee. Left out when the quote has no delivery charge, as for pickup, or a
381
+ * delivery with no address yet.
382
+ */
383
+ delivery?: Money;
384
+ /** A perk's discount has code `perk` and the `redemptionId` it comes from. */
385
+ discounts: {
386
+ code: string;
387
+ label: string;
388
+ amount: Money;
389
+ redemptionId?: string;
390
+ }[];
391
+ /** The subtotal plus the fees, delivery and discounts. Discount amounts are negative. */
392
+ total: Money;
393
+ /**
394
+ * Everything the quote found, in the order it found it. These are the quote's issues only. The
395
+ * cart's `issues` adds its own checks.
396
+ */
397
+ issues: CartIssue[];
398
+ /** False when any issue is blocking or a delivery has no address yet. */
399
+ canCheckout: boolean;
400
+ /** Whether you can open a checkout session next. Use it to show the right button. */
401
+ checkout: {
402
+ /** True when you can open a checkout session for this cart now. */
403
+ ready: boolean;
404
+ /**
405
+ * Why checkout is not ready. `issues` means a blocking issue stops it. `customer_required`
406
+ * means the cart needs a signed-in customer. Left out when checkout is ready, for a delivery
407
+ * that only needs its address, and for a reason newer than this SDK.
408
+ */
409
+ reason?: "issues" | "customer_required";
410
+ /** The store's checkout field keys this cart asks for, in display order. */
411
+ fields?: string[];
412
+ };
413
+ /**
414
+ * The branch's current menu version, which names the state of its menus. Compare the whole
415
+ * string and don't parse it. When it differs from the cart's menu, the cart refreshes the menu
416
+ * and quotes again.
417
+ */
418
+ menuVersion: string;
419
+ /**
420
+ * When the quote expires, 15 minutes after it was made, as an RFC 3339 date and time in UTC.
421
+ * Until then the cart reuses it for an unchanged cart. Checkout prices the cart again, so it
422
+ * never refuses a quote for being old.
423
+ */
424
+ expiresAt: string;
425
+ };
426
+ /**
427
+ * The cart validation and quoting state, with a quote or issues when available.
428
+ */
429
+ type CartState = {
430
+ status: "ready";
431
+ } | {
432
+ status: "quoting";
433
+ } | {
434
+ status: "quoted";
435
+ quote: Quote;
436
+ } | {
437
+ status: "needs_attention";
438
+ quote?: Quote;
439
+ issues: readonly CartIssue[];
440
+ };
441
+ /**
442
+ * A loyalty perk the shopper redeemed into the bag. The quote prices it, and checkout spends it.
443
+ */
444
+ type AppliedPerk = Readonly<{
445
+ redemptionId: string;
446
+ perkId: string;
447
+ name: string;
448
+ pointsSpent: number;
449
+ /** When the reservation gives its points back if no order uses it. */
450
+ expiresAt: string;
451
+ /**
452
+ * What the perk gives, when the perk was applied from the perk list. `order_discount` takes an
453
+ * amount or a percentage off the order. `free_item` gives items for free.
454
+ */
455
+ reward?: "order_discount" | "free_item";
456
+ }>;
457
+ /**
458
+ * The current readonly cart view, including lines, branch, fulfilment and hydration state.
459
+ */
460
+ type CartSnapshot = {
461
+ /** Selected branch remains available before a fulfilment mode is chosen. */
462
+ readonly branchId?: string | undefined;
463
+ /** The lines in the order they were added. */
464
+ readonly lines: readonly CartLine[];
465
+ /** The number of units across every line. */
466
+ readonly count: number;
467
+ /**
468
+ * The sum of the lines' local estimates, before charges and discounts. Null when a line can't be
469
+ * priced from the menu the cart holds. The quote's `subtotal` is the price to trust.
470
+ */
471
+ readonly subtotal: Money | null;
472
+ /**
473
+ * How the shopper gets the order. Null until you call `setFulfilment`, and again after `clear` or
474
+ * `moveTo`. A saved delivery is dropped after 24 hours without a change, and a scheduled time
475
+ * already past is removed when the cart loads.
476
+ */
477
+ readonly fulfilment: CartFulfilment | null;
478
+ /** The promo code sent with each quote and checkout, trimmed. Null when there is none. */
479
+ readonly promoCode: string | null;
480
+ /** The perks redeemed into the bag, sent with each quote and checkout. Never on an in-venue order. */
481
+ readonly perks: readonly AppliedPerk[];
482
+ /** Where the cart is in validating and quoting, with the latest quote when it has one. */
483
+ readonly state: CartState;
484
+ /**
485
+ * Every open issue: the cart's own checks first, then the quote's issues that the cart doesn't
486
+ * already report.
487
+ */
488
+ readonly issues: readonly CartIssue[];
489
+ /**
490
+ * True once the cart has loaded the saved cart for its branch, by `hydrate`, `mount` or the first
491
+ * edit.
492
+ */
493
+ readonly isHydrated: boolean;
494
+ };
495
+ /**
496
+ * Cart state and operations for editing lines, quoting, persistence and subscriptions.
497
+ */
498
+ interface CartModule extends CartSnapshot {
499
+ /**
500
+ * Check a line before you add it. An input without a `menuId` is checked against the menu `add`
501
+ * would file it under, `withDefaultMenu`.
502
+ */
503
+ validate(input: CartLineInput): {
504
+ ok: true;
505
+ } | {
506
+ ok: false;
507
+ issues: CartIssue[];
508
+ };
509
+ /**
510
+ * Add a line, or add its quantity to an equal line. Without a `menuId`, an item on more than one
511
+ * of the branch's menus goes under the first of them in display order, and follows that menu's
512
+ * hours and pre-order terms. Pass `menuId` when the shopper opened the item from a menu.
513
+ * Throws `ZappieCartError` when the line is invalid, for example when no menu lists the item.
514
+ */
515
+ add(item: Item | string, input?: Omit<CartLineInput, "itemId">): CartLine;
516
+ /**
517
+ * Change a line and return it. Fields you leave out keep their values. A patch with `choices`
518
+ * and no `variantId` picks the variant again. A change that makes the line equal to another
519
+ * merges the two. Throws `ZappieCartError` with `item_not_found` when the cart has no such line,
520
+ * or with the line's issues when the change is invalid.
521
+ * @param lineId - The ID of the cart line to change.
522
+ * @param patch - The fields to change.
523
+ */
524
+ update(lineId: string, patch: Partial<Omit<CartLineInput, "itemId">>): CartLine;
525
+ /** Take a line out of the cart. An ID the cart doesn't hold changes nothing. */
526
+ remove(lineId: string): void;
527
+ /** Empty the cart, and drop its fulfilment, promo code and perks. */
528
+ clear(): void;
529
+ /**
530
+ * Set how the shopper gets the order. Throws `ZappieCartError` with `fulfilment_unavailable`
531
+ * when the selection is invalid or names another branch than the cart's.
532
+ */
533
+ setFulfilment(fulfilment: CartFulfilment): void;
534
+ /** Set the promo code to send with each quote and checkout. Null or a blank code removes it. */
535
+ setPromoCode(code: string | null): void;
536
+ /**
537
+ * Set what the shopper typed for the store's checkout fields. Each quote and the checkout send it.
538
+ * It stays in memory only, never in the saved cart.
539
+ */
540
+ setCustomer(customer: CheckoutCustomer | null): void;
541
+ /**
542
+ * Replace the perks the cart sends. Use `applyPerk` and `removePerk` from `@zappie/sdk/loyalty`,
543
+ * which redeem and cancel them with the API first.
544
+ */
545
+ setPerks(perks: readonly AppliedPerk[]): void;
546
+ /**
547
+ * Price the bag for delivery at a time before the shopper gives the address
548
+ * (`PendingFulfilment`), or stop with null. Quotes send it only while the cart holds no
549
+ * fulfilment, and `setFulfilment` with the address takes over. It stays in memory only.
550
+ */
551
+ setPendingFulfilment(pending: PendingFulfilment | null): void;
552
+ /**
553
+ * Ask the API to price the cart and resolve with the quote. A cart with lines also quotes by
554
+ * itself 300 milliseconds after each change. An unchanged cart gets its last quote back until it expires,
555
+ * and a cart that just failed to price throws the same error for 30 seconds.
556
+ * @param opts - Set `force` to ask the API again in either case.
557
+ */
558
+ quote(opts?: {
559
+ force?: boolean;
560
+ }): Promise<Quote>;
561
+ /** Handle interactive fixes by calling the option, address or time setter. */
562
+ applyFix(issue: CartIssue, fix?: CartFix): void;
563
+ /**
564
+ * Move the cart to another branch of the store. Lines the new branch can't sell are dropped,
565
+ * each with an `item_unavailable` warning, and the fulfilment, promo code and perks are cleared.
566
+ * The old branch's saved cart is removed.
567
+ * @param branchId - The ID of the branch to move to.
568
+ */
569
+ moveTo(branchId: string): Promise<void>;
570
+ /**
571
+ * Load the store, the branch's menu and the saved cart. It then asks for a quote when the cart
572
+ * has none, and refreshes the menu when its version changed. On a loaded cart it does only that.
573
+ */
574
+ hydrate(): Promise<void>;
575
+ /** Attach browser listeners. Use the returned cleanup in your component effect. */
576
+ mount(): () => void;
577
+ /** Stop the cart for good: cancel its quotes, detach its listeners and drop its subscribers. */
578
+ dispose(): void;
579
+ /**
580
+ * Call `fn` after each change to the cart's snapshot. Returns a function that unsubscribes. It
581
+ * fits `useSyncExternalStore` with `getSnapshot`.
582
+ */
583
+ subscribe(fn: () => void): () => void;
584
+ /** The current snapshot. It is frozen and only replaced when the cart changes. */
585
+ getSnapshot(): CartSnapshot;
586
+ /**
587
+ * The cart as a checkout request body, in API field names. Throws `ZappieCartError` with the
588
+ * blocking issues, or with `fulfilment_unavailable` when the cart has no lines or no
589
+ * fulfilment.
590
+ */
591
+ toCheckoutPayload(): {
592
+ lines: WireLine[];
593
+ fulfilment: CartFulfilment;
594
+ promo_code?: string;
595
+ perk_redemption_ids?: string[];
596
+ customer?: CheckoutCustomer;
597
+ menu_version: string;
598
+ };
599
+ }
600
+ /**
601
+ * A cart line serialized with API field names for quote and checkout requests.
602
+ */
603
+ type WireLine = {
604
+ /** The cart line's ID. The quote returns it unchanged. */
605
+ line_id: string;
606
+ /** The item's ID. */
607
+ item_id: string;
608
+ /**
609
+ * The menu the shopper chose the item from. The API needs it when the item is on more than one
610
+ * menu.
611
+ */
612
+ menu_id?: string;
613
+ /** How many units, from 1 to 99. */
614
+ quantity: number;
615
+ /** The exact variant. The API needs it when the item has attribute groups. */
616
+ variant_id?: string;
617
+ /** The choices picked in option groups, each with how many units of it. */
618
+ options: {
619
+ group_id: string;
620
+ choice_id: string;
621
+ quantity: number;
622
+ }[];
623
+ /** What the shopper typed for each input group, keyed by group ID. */
624
+ inputs: Record<string, string>;
625
+ /** The shopper's note for this line. It goes on the order. */
626
+ note?: string;
627
+ };
628
+ /**
629
+ * A fulfilment selection serialized with API field names, without its branch ID.
630
+ */
631
+ type WireFulfilment = {
632
+ /** Selected delivery region in API field names. */
633
+ delivery_region_id?: string;
634
+ /** Delivery instructions sent alongside the address. */
635
+ instructions?: string;
636
+ /** How the shopper gets the order. */
637
+ type: CartFulfilment["type"];
638
+ /** When the order is for, as an RFC 3339 date and time. Left out for as soon as possible. */
639
+ scheduled_for?: string;
640
+ /** The dine-in table the shopper typed. The quote request to the API leaves it out. */
641
+ table?: string;
642
+ /**
643
+ * Where to deliver, on a delivery. Requests to the API leave out `line2` and send
644
+ * `instructions` as the fulfilment's `instructions`.
645
+ */
646
+ address?: {
647
+ line1: string;
648
+ line2?: string;
649
+ city?: string;
650
+ place_id?: string;
651
+ lat?: number;
652
+ lng?: number;
653
+ instructions?: string;
654
+ };
655
+ };
656
+ /**
657
+ * The branch, menu version and cart contents you send for a server quote.
658
+ */
659
+ type QuoteRequest = {
660
+ /** The branch to price the cart at. */
661
+ branch_id: string;
662
+ /** The cart's lines, 100 at most. */
663
+ lines: WireLine[];
664
+ /**
665
+ * How the shopper gets the order. Left out until the shopper chooses, and the quote then prices
666
+ * the mode the catalogue defaults to.
667
+ */
668
+ fulfilment?: WireFulfilment;
669
+ /**
670
+ * The promo code to apply. A code that doesn't apply comes back as `promo_invalid` or
671
+ * `promo_min_spend`.
672
+ */
673
+ promo_code?: string;
674
+ /**
675
+ * The customer's reserved perk redemptions to apply. The cart leaves them out of a dine-in order.
676
+ */
677
+ perk_redemption_ids?: string[];
678
+ /** What the shopper typed for the store's checkout fields. Left out when nothing is set. */
679
+ customer?: CheckoutCustomer;
680
+ /**
681
+ * The menu version the cart was built against. When the menu has changed since, the quote
682
+ * reports `menu_version_stale`.
683
+ */
684
+ menu_version: string;
685
+ };
686
+ /**
687
+ * An API monetary amount in minor units with its currency code.
688
+ */
689
+ type WireMoney = {
690
+ /** The amount in minor units of the currency, such as kobo or cents. */
691
+ amount_minor: number;
692
+ /** The ISO 4217 currency code. */
693
+ currency: Currency;
694
+ };
695
+ /**
696
+ * A suggested cart correction in API field names, before conversion to CartFix.
697
+ */
698
+ type WireFix = {
699
+ /**
700
+ * What to offer the shopper, as in `CartFix`. The SDK drops any action it doesn't know.
701
+ */
702
+ action: CartFix["action"];
703
+ /** On `choose_option` and `choose_other_option`, the option group. */
704
+ group_id?: string;
705
+ /** On `fill_field`, the checkout field's key. */
706
+ field?: string;
707
+ /** On `schedule`, when the branch or the menu opens next, in UTC. */
708
+ next_open_at?: string;
709
+ /** On `set_quantity`, the nearest allowed quantity. */
710
+ quantity?: number;
711
+ /** Reserved for times the shopper can choose. The API doesn't send it today. */
712
+ slots?: string[];
713
+ /** On `switch_fulfilment`, the modes the branch offers. */
714
+ types?: CartFulfilment["type"][];
715
+ };
716
+ /**
717
+ * A server cart issue in API field names, before adding its quote source.
718
+ */
719
+ type WireIssue = Omit<CartIssue, "source" | "lineId" | "groupId" | "fixes"> & {
720
+ line_id?: string;
721
+ fixes: WireFix[];
722
+ };
723
+ /**
724
+ * The server quote response in API field names, including prices, charges and checkout readiness.
725
+ */
726
+ type WireQuote = {
727
+ /** Whether the submitted menu version is stale. */
728
+ menu_version_stale?: boolean;
729
+ /** Fulfilment details returned by the quote service. */
730
+ fulfilment?: {
731
+ type: string;
732
+ scheduled_for: string | null;
733
+ eta_minutes?: number[];
734
+ delivery_region_id?: string;
735
+ };
736
+ /**
737
+ * The branch the quote priced. The SDK refuses a response for another branch than it asked
738
+ * about.
739
+ */
740
+ branch_id: string;
741
+ /** The branch's current menu version. */
742
+ menu_version: string;
743
+ /** When the quote expires, 15 minutes after it was made, as an RFC 3339 date and time in UTC. */
744
+ expires_at: string;
745
+ /** True when you can't trust the per-line prices. The overall totals still hold. */
746
+ lines_unpriced?: boolean;
747
+ /** The request's lines, in the same order, each with its price and status. */
748
+ lines: {
749
+ line_id: string;
750
+ item_id?: string;
751
+ name?: string;
752
+ quantity?: number;
753
+ options_total?: WireMoney | null;
754
+ status?: string;
755
+ unit_price: WireMoney | null;
756
+ line_total: WireMoney | null;
757
+ }[];
758
+ /** What the lines cost before charges and discounts. A line with status `invalid` isn't in it. */
759
+ subtotal: WireMoney;
760
+ /**
761
+ * What the order adds on top, delivery included. The SDK splits the `delivery` charge into
762
+ * `Quote.delivery` and the rest into `Quote.fees`. A charge at zero is left out.
763
+ */
764
+ charges: {
765
+ code: string;
766
+ label: string;
767
+ amount: WireMoney;
768
+ }[];
769
+ /**
770
+ * The discounts, with negative amounts. A perk's discount has code `perk` and its
771
+ * `redemption_id`.
772
+ */
773
+ discounts: {
774
+ code: string;
775
+ label: string;
776
+ amount: WireMoney;
777
+ redemption_id?: string;
778
+ }[];
779
+ /** The subtotal plus the charges and discounts. */
780
+ total: WireMoney;
781
+ /** Everything the quote found, in the order it found it. */
782
+ issues: WireIssue[];
783
+ /** False when any issue is blocking or a delivery has no address yet. */
784
+ can_checkout: boolean;
785
+ /** Whether you can open a checkout session next, as in `Quote.checkout`. */
786
+ checkout: {
787
+ ready: boolean;
788
+ reason?: "issues" | "customer_required";
789
+ fields?: string[];
790
+ };
791
+ };
792
+ /** A saved cart with its scope, revision and expiry. */
793
+ type CartSyncDocument = {
794
+ /** The document's format version. Always 1. */
795
+ schemaVersion: 1;
796
+ /** The store the cart belongs to. */
797
+ store: string;
798
+ /** The branch the cart belongs to. */
799
+ branchId: string;
800
+ /** An opaque revision the server gives each saved version. Pass it back as `expectedRevision`. */
801
+ revision: string;
802
+ /** When the server drops the saved cart, as set by the server. */
803
+ expiresAt: string;
804
+ /** The cart's lines, in API field names. */
805
+ lines: WireLine[];
806
+ /** How the shopper gets the order. Null when none is chosen. */
807
+ fulfilment: CartFulfilment | null;
808
+ /** The cart's promo code. Null when there is none. */
809
+ promoCode: string | null;
810
+ };
811
+ /**
812
+ * A storage adapter for reading cart documents and writing them with revision checks.
813
+ * Writes return the saved document or the current document when revisions conflict.
814
+ */
815
+ interface CartSyncAdapter {
816
+ /**
817
+ * Read the saved cart for a store and branch. Resolves with null when there is none. The SDK
818
+ * doesn't call an adapter today.
819
+ */
820
+ read(scope: {
821
+ store: string;
822
+ branchId: string;
823
+ }, signal?: AbortSignal): Promise<CartSyncDocument | null>;
824
+ /** Write if the revision matches. Reuse the operation ID when you retry to avoid applying a change twice. */
825
+ write(document: Omit<CartSyncDocument, "revision" | "expiresAt">, options: {
826
+ expectedRevision: string | null;
827
+ operationId: string;
828
+ signal?: AbortSignal;
829
+ }): Promise<{
830
+ status: "saved";
831
+ document: CartSyncDocument;
832
+ } | {
833
+ status: "conflict";
834
+ document: CartSyncDocument;
835
+ }>;
836
+ }
837
+
838
+ export type { AppliedPerk as A, CartLine as C, DeliveryAddress as D, PendingFulfilment as P, QuoteRequest as Q, WireFulfilment as W, Quote as a, CartLineInput as b, CartFulfilment as c, CartModule as d, CartIssueCode as e, CartState as f, CartIssue as g, WireMoney as h, WireQuote as i, CartFix as j, CartSnapshot as k, CartSyncAdapter as l, CartSyncDocument as m, CheckoutCustomer as n, WireFix as o, WireIssue as p, WireLine as q };