@aglyn/plugins-commerce 1.0.0-beta.229 → 1.0.0-beta.231

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 (590) hide show
  1. package/package.json +13 -13
  2. package/src/index.d.ts +0 -1
  3. package/src/index.js +0 -1
  4. package/src/index.js.map +1 -1
  5. package/src/lib/barcode/barcode-decode.d.ts +71 -0
  6. package/src/lib/barcode/barcode-decode.js +498 -0
  7. package/src/lib/barcode/barcode-decode.js.map +1 -0
  8. package/src/lib/barcode/barcode-encode.d.ts +44 -0
  9. package/src/lib/barcode/barcode-encode.js +138 -0
  10. package/src/lib/barcode/barcode-encode.js.map +1 -0
  11. package/src/lib/barcode/barcode-scanner.component.d.ts +23 -0
  12. package/src/lib/barcode/barcode-scanner.component.js +260 -0
  13. package/src/lib/barcode/barcode-scanner.component.js.map +1 -0
  14. package/src/lib/barcode/scan-button.component.d.ts +10 -0
  15. package/src/lib/barcode/scan-button.component.js +62 -0
  16. package/src/lib/barcode/scan-button.component.js.map +1 -0
  17. package/src/lib/barcode/scanner-wedge.d.ts +35 -0
  18. package/src/lib/barcode/scanner-wedge.js +108 -0
  19. package/src/lib/barcode/scanner-wedge.js.map +1 -0
  20. package/src/lib/components/account.js +10 -1
  21. package/src/lib/components/account.js.map +1 -1
  22. package/src/lib/components/cart-extras.d.ts +45 -0
  23. package/src/lib/components/cart-extras.js +127 -0
  24. package/src/lib/components/cart-extras.js.map +1 -0
  25. package/src/lib/components/cart.js +82 -15
  26. package/src/lib/components/cart.js.map +1 -1
  27. package/src/lib/components/checkout-return-notice.d.ts +26 -0
  28. package/src/lib/components/checkout-return-notice.js +48 -0
  29. package/src/lib/components/checkout-return-notice.js.map +1 -0
  30. package/src/lib/components/commerce-console-page.js +124 -0
  31. package/src/lib/components/commerce-console-page.js.map +1 -1
  32. package/src/lib/components/commerce-console-sections.d.ts +1 -1
  33. package/src/lib/components/commerce-console-sections.js +4 -0
  34. package/src/lib/components/commerce-console-sections.js.map +1 -1
  35. package/src/lib/components/console/bulk-fulfill.d.ts +44 -0
  36. package/src/lib/components/console/bulk-fulfill.js +84 -0
  37. package/src/lib/components/console/bulk-fulfill.js.map +1 -0
  38. package/src/lib/components/console/customer-notifications-card.component.d.ts +19 -0
  39. package/src/lib/components/console/customer-notifications-card.component.js +149 -0
  40. package/src/lib/components/console/customer-notifications-card.component.js.map +1 -0
  41. package/src/lib/components/console/host-orders-card.component.js +84 -5
  42. package/src/lib/components/console/host-orders-card.component.js.map +1 -1
  43. package/src/lib/components/console/locations-card.component.js +164 -57
  44. package/src/lib/components/console/locations-card.component.js.map +1 -1
  45. package/src/lib/components/console/order-detail-dialog.component.js +209 -61
  46. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
  47. package/src/lib/components/console/order-fulfillment-panel.component.d.ts +48 -0
  48. package/src/lib/components/console/order-fulfillment-panel.component.js +542 -0
  49. package/src/lib/components/console/order-fulfillment-panel.component.js.map +1 -0
  50. package/src/lib/components/console/order-invoice.component.d.ts +33 -0
  51. package/src/lib/components/console/order-invoice.component.js +81 -0
  52. package/src/lib/components/console/order-invoice.component.js.map +1 -0
  53. package/src/lib/components/console/order-receipt-resend.component.d.ts +21 -0
  54. package/src/lib/components/console/order-receipt-resend.component.js +203 -0
  55. package/src/lib/components/console/order-receipt-resend.component.js.map +1 -0
  56. package/src/lib/components/console/order-returns.component.d.ts +36 -0
  57. package/src/lib/components/console/order-returns.component.js +142 -0
  58. package/src/lib/components/console/order-returns.component.js.map +1 -0
  59. package/src/lib/components/console/order-shipping-actions.component.d.ts +54 -0
  60. package/src/lib/components/console/order-shipping-actions.component.js +149 -0
  61. package/src/lib/components/console/order-shipping-actions.component.js.map +1 -0
  62. package/src/lib/components/console/order-webhooks-card.component.d.ts +50 -0
  63. package/src/lib/components/console/order-webhooks-card.component.js +623 -0
  64. package/src/lib/components/console/order-webhooks-card.component.js.map +1 -0
  65. package/src/lib/components/console/order-zones.d.ts +155 -0
  66. package/src/lib/components/console/order-zones.js +40 -0
  67. package/src/lib/components/console/order-zones.js.map +1 -0
  68. package/src/lib/components/console/payment-methods-card.component.d.ts +67 -0
  69. package/src/lib/components/console/payment-methods-card.component.js +395 -0
  70. package/src/lib/components/console/payment-methods-card.component.js.map +1 -0
  71. package/src/lib/components/console/pos/pos-api.d.ts +124 -0
  72. package/src/lib/components/console/pos/pos-api.js +101 -0
  73. package/src/lib/components/console/pos/pos-api.js.map +1 -0
  74. package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +36 -0
  75. package/src/lib/components/console/pos/pos-cart-panel.component.js +160 -0
  76. package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -0
  77. package/src/lib/components/console/pos/pos-item-dialog.component.d.ts +39 -0
  78. package/src/lib/components/console/pos/pos-item-dialog.component.js +352 -0
  79. package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -0
  80. package/src/lib/components/console/pos/pos-product-grid.component.d.ts +47 -0
  81. package/src/lib/components/console/pos/pos-product-grid.component.js +272 -0
  82. package/src/lib/components/console/pos/pos-product-grid.component.js.map +1 -0
  83. package/src/lib/components/console/pos/pos-receipt-panel.component.d.ts +27 -0
  84. package/src/lib/components/console/pos/pos-receipt-panel.component.js +282 -0
  85. package/src/lib/components/console/pos/pos-receipt-panel.component.js.map +1 -0
  86. package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +53 -0
  87. package/src/lib/components/console/pos/pos-tender-dialogs.component.js +445 -0
  88. package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -0
  89. package/src/lib/components/console/pos/pos-tender-panel.component.d.ts +31 -0
  90. package/src/lib/components/console/pos/pos-tender-panel.component.js +640 -0
  91. package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -0
  92. package/src/lib/components/console/pos/use-pos-display.d.ts +43 -0
  93. package/src/lib/components/console/pos/use-pos-display.js +161 -0
  94. package/src/lib/components/console/pos/use-pos-display.js.map +1 -0
  95. package/src/lib/components/console/pos-devices-card.component.d.ts +14 -0
  96. package/src/lib/components/console/pos-devices-card.component.js +546 -0
  97. package/src/lib/components/console/pos-devices-card.component.js.map +1 -0
  98. package/src/lib/components/console/pos-display/brand-screen.d.ts +33 -0
  99. package/src/lib/components/console/pos-display/brand-screen.js +85 -0
  100. package/src/lib/components/console/pos-display/brand-screen.js.map +1 -0
  101. package/src/lib/components/console/pos-display/cart-screen.d.ts +29 -0
  102. package/src/lib/components/console/pos-display/cart-screen.js +166 -0
  103. package/src/lib/components/console/pos-display/cart-screen.js.map +1 -0
  104. package/src/lib/components/console/pos-display/pairing-screen.d.ts +24 -0
  105. package/src/lib/components/console/pos-display/pairing-screen.js +127 -0
  106. package/src/lib/components/console/pos-display/pairing-screen.js.map +1 -0
  107. package/src/lib/components/console/pos-display/pos-display-api.d.ts +90 -0
  108. package/src/lib/components/console/pos-display/pos-display-api.js +140 -0
  109. package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -0
  110. package/src/lib/components/console/pos-display/receipt-screen.d.ts +35 -0
  111. package/src/lib/components/console/pos-display/receipt-screen.js +200 -0
  112. package/src/lib/components/console/pos-display/receipt-screen.js.map +1 -0
  113. package/src/lib/components/console/pos-display/tip-screen.d.ts +36 -0
  114. package/src/lib/components/console/pos-display/tip-screen.js +211 -0
  115. package/src/lib/components/console/pos-display/tip-screen.js.map +1 -0
  116. package/src/lib/components/console/pos-display-page.component.d.ts +16 -0
  117. package/src/lib/components/console/pos-display-page.component.js +407 -0
  118. package/src/lib/components/console/pos-display-page.component.js.map +1 -0
  119. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.d.ts +40 -0
  120. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js +289 -0
  121. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js.map +1 -0
  122. package/src/lib/components/console/pos-ops/pos-last-receipt.component.d.ts +34 -0
  123. package/src/lib/components/console/pos-ops/pos-last-receipt.component.js +61 -0
  124. package/src/lib/components/console/pos-ops/pos-last-receipt.component.js.map +1 -0
  125. package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +38 -0
  126. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +129 -0
  127. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -0
  128. package/src/lib/components/console/pos-ops/pos-ops-api.d.ts +37 -0
  129. package/src/lib/components/console/pos-ops/pos-ops-api.js +60 -0
  130. package/src/lib/components/console/pos-ops/pos-ops-api.js.map +1 -0
  131. package/src/lib/components/console/pos-ops/pos-pin-pad.component.d.ts +48 -0
  132. package/src/lib/components/console/pos-ops/pos-pin-pad.component.js +220 -0
  133. package/src/lib/components/console/pos-ops/pos-pin-pad.component.js.map +1 -0
  134. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.d.ts +63 -0
  135. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js +186 -0
  136. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js.map +1 -0
  137. package/src/lib/components/console/pos-ops/pos-receipt.d.ts +39 -0
  138. package/src/lib/components/console/pos-ops/pos-receipt.js +182 -0
  139. package/src/lib/components/console/pos-ops/pos-receipt.js.map +1 -0
  140. package/src/lib/components/console/pos-ops/pos-return-dialog.component.d.ts +40 -0
  141. package/src/lib/components/console/pos-ops/pos-return-dialog.component.js +465 -0
  142. package/src/lib/components/console/pos-ops/pos-return-dialog.component.js.map +1 -0
  143. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.d.ts +29 -0
  144. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js +253 -0
  145. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js.map +1 -0
  146. package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +34 -0
  147. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +494 -0
  148. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -0
  149. package/src/lib/components/console/pos-ops/pos-shift-report.component.d.ts +37 -0
  150. package/src/lib/components/console/pos-ops/pos-shift-report.component.js +102 -0
  151. package/src/lib/components/console/pos-ops/pos-shift-report.component.js.map +1 -0
  152. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.d.ts +30 -0
  153. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js +277 -0
  154. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js.map +1 -0
  155. package/src/lib/components/console/pos-ops/register-ops.d.ts +28 -0
  156. package/src/lib/components/console/pos-ops/register-ops.js +28 -0
  157. package/src/lib/components/console/pos-ops/register-ops.js.map +1 -0
  158. package/src/lib/components/console/pos-ops/use-pos-cashier.d.ts +46 -0
  159. package/src/lib/components/console/pos-ops/use-pos-cashier.js +128 -0
  160. package/src/lib/components/console/pos-ops/use-pos-cashier.js.map +1 -0
  161. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.d.ts +36 -0
  162. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js +64 -0
  163. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js.map +1 -0
  164. package/src/lib/components/console/pos-page.component.d.ts +13 -5
  165. package/src/lib/components/console/pos-page.component.js +729 -657
  166. package/src/lib/components/console/pos-page.component.js.map +1 -1
  167. package/src/lib/components/console/product-editor-dialog.component.js +51 -7
  168. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  169. package/src/lib/components/console/product-labels-dialog.component.d.ts +13 -0
  170. package/src/lib/components/console/product-labels-dialog.component.js +197 -0
  171. package/src/lib/components/console/product-labels-dialog.component.js.map +1 -0
  172. package/src/lib/components/console/product-register-fields.component.d.ts +19 -0
  173. package/src/lib/components/console/product-register-fields.component.js +241 -0
  174. package/src/lib/components/console/product-register-fields.component.js.map +1 -0
  175. package/src/lib/components/console/product-zones.d.ts +58 -2
  176. package/src/lib/components/console/product-zones.js +10 -2
  177. package/src/lib/components/console/product-zones.js.map +1 -1
  178. package/src/lib/components/console/products-hub-card.component.js +51 -11
  179. package/src/lib/components/console/products-hub-card.component.js.map +1 -1
  180. package/src/lib/components/console/register-hardware-card.component.d.ts +33 -0
  181. package/src/lib/components/console/register-hardware-card.component.js +826 -0
  182. package/src/lib/components/console/register-hardware-card.component.js.map +1 -0
  183. package/src/lib/components/console/registers-card.component.js +24 -5
  184. package/src/lib/components/console/registers-card.component.js.map +1 -1
  185. package/src/lib/components/console/return-actions.d.ts +38 -0
  186. package/src/lib/components/console/return-actions.js +76 -0
  187. package/src/lib/components/console/return-actions.js.map +1 -0
  188. package/src/lib/components/console/return-detail-dialog.component.d.ts +34 -0
  189. package/src/lib/components/console/return-detail-dialog.component.js +718 -0
  190. package/src/lib/components/console/return-detail-dialog.component.js.map +1 -0
  191. package/src/lib/components/console/return-settings-card.component.d.ts +34 -0
  192. package/src/lib/components/console/return-settings-card.component.js +195 -0
  193. package/src/lib/components/console/return-settings-card.component.js.map +1 -0
  194. package/src/lib/components/console/return-zones.d.ts +87 -0
  195. package/src/lib/components/console/return-zones.js +31 -0
  196. package/src/lib/components/console/return-zones.js.map +1 -0
  197. package/src/lib/components/console/returns-card.component.d.ts +45 -0
  198. package/src/lib/components/console/returns-card.component.js +159 -0
  199. package/src/lib/components/console/returns-card.component.js.map +1 -0
  200. package/src/lib/components/console/shipping-settings-card.component.js +161 -5
  201. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
  202. package/src/lib/components/console/shippingeasy-card.component.d.ts +59 -0
  203. package/src/lib/components/console/shippingeasy-card.component.js +378 -0
  204. package/src/lib/components/console/shippingeasy-card.component.js.map +1 -0
  205. package/src/lib/components/console/shipstation-card.component.d.ts +35 -0
  206. package/src/lib/components/console/shipstation-card.component.js +345 -0
  207. package/src/lib/components/console/shipstation-card.component.js.map +1 -0
  208. package/src/lib/components/console/start-return-dialog.component.d.ts +40 -0
  209. package/src/lib/components/console/start-return-dialog.component.js +243 -0
  210. package/src/lib/components/console/start-return-dialog.component.js.map +1 -0
  211. package/src/lib/components/console/stock-movements-card.component.js +2 -1
  212. package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
  213. package/src/lib/components/console/store-settings-card.component.js +2 -66
  214. package/src/lib/components/console/store-settings-card.component.js.map +1 -1
  215. package/src/lib/components/console/store-zones.d.ts +42 -0
  216. package/src/lib/components/console/store-zones.js +39 -0
  217. package/src/lib/components/console/store-zones.js.map +1 -0
  218. package/src/lib/components/order-status.d.ts +36 -0
  219. package/src/lib/components/order-status.js +502 -0
  220. package/src/lib/components/order-status.js.map +1 -0
  221. package/src/lib/components/product-detail.js +44 -2
  222. package/src/lib/components/product-detail.js.map +1 -1
  223. package/src/lib/components/return-request.d.ts +32 -0
  224. package/src/lib/components/return-request.js +576 -0
  225. package/src/lib/components/return-request.js.map +1 -0
  226. package/src/lib/components/storefront-payment-appearance.d.ts +32 -0
  227. package/src/lib/components/storefront-payment-appearance.js +114 -0
  228. package/src/lib/components/storefront-payment-appearance.js.map +1 -0
  229. package/src/lib/components/storefront-payment-element.d.ts +57 -1
  230. package/src/lib/components/storefront-payment-element.js +332 -33
  231. package/src/lib/components/storefront-payment-element.js.map +1 -1
  232. package/src/lib/constants/order-status.d.ts +22 -0
  233. package/src/lib/constants/order-status.js +22 -0
  234. package/src/lib/constants/order-status.js.map +1 -0
  235. package/src/lib/constants/return-request.d.ts +27 -0
  236. package/src/lib/constants/return-request.js +32 -0
  237. package/src/lib/constants/return-request.js.map +1 -0
  238. package/src/lib/constants/stock-movement-query.js +2 -1
  239. package/src/lib/constants/stock-movement-query.js.map +1 -1
  240. package/src/lib/declarations.console-server.js +9 -0
  241. package/src/lib/declarations.console-server.js.map +1 -1
  242. package/src/lib/declarations.server.d.ts +2 -1
  243. package/src/lib/declarations.server.js +47 -1
  244. package/src/lib/declarations.server.js.map +1 -1
  245. package/src/lib/model/buyer-notifications.d.ts +59 -0
  246. package/src/lib/model/buyer-notifications.js +97 -0
  247. package/src/lib/model/buyer-notifications.js.map +1 -0
  248. package/src/lib/model/commerce-orders.d.ts +127 -1
  249. package/src/lib/model/commerce-orders.js +24 -15
  250. package/src/lib/model/commerce-orders.js.map +1 -1
  251. package/src/lib/model/commerce-payment-methods.d.ts +146 -0
  252. package/src/lib/model/commerce-payment-methods.js +247 -0
  253. package/src/lib/model/commerce-payment-methods.js.map +1 -0
  254. package/src/lib/model/commerce-pos-ops.d.ts +437 -0
  255. package/src/lib/model/commerce-pos-ops.js +721 -0
  256. package/src/lib/model/commerce-pos-ops.js.map +1 -0
  257. package/src/lib/model/commerce-pos.d.ts +263 -0
  258. package/src/lib/model/commerce-pos.js +375 -0
  259. package/src/lib/model/commerce-pos.js.map +1 -0
  260. package/src/lib/model/commerce-printers.d.ts +211 -0
  261. package/src/lib/model/commerce-printers.js +181 -0
  262. package/src/lib/model/commerce-printers.js.map +1 -0
  263. package/src/lib/model/commerce-receipt.d.ts +97 -0
  264. package/src/lib/model/commerce-receipt.js +180 -0
  265. package/src/lib/model/commerce-receipt.js.map +1 -0
  266. package/src/lib/model/commerce-returns.d.ts +207 -0
  267. package/src/lib/model/commerce-returns.js +300 -0
  268. package/src/lib/model/commerce-returns.js.map +1 -0
  269. package/src/lib/model/commerce-shipping.d.ts +44 -1
  270. package/src/lib/model/commerce-shipping.js +53 -9
  271. package/src/lib/model/commerce-shipping.js.map +1 -1
  272. package/src/lib/model/commerce-tax-engine.d.ts +90 -0
  273. package/src/lib/model/commerce-tax-engine.js +129 -0
  274. package/src/lib/model/commerce-tax-engine.js.map +1 -0
  275. package/src/lib/model/commerce.d.ts +88 -2
  276. package/src/lib/model/commerce.js +89 -1
  277. package/src/lib/model/commerce.js.map +1 -1
  278. package/src/lib/model/index.d.ts +15 -0
  279. package/src/lib/model/index.js +15 -0
  280. package/src/lib/model/index.js.map +1 -1
  281. package/src/lib/model/order-events.d.ts +154 -0
  282. package/src/lib/model/order-events.js +153 -0
  283. package/src/lib/model/order-events.js.map +1 -0
  284. package/src/lib/model/order-fulfillment.d.ts +117 -0
  285. package/src/lib/model/order-fulfillment.js +217 -0
  286. package/src/lib/model/order-fulfillment.js.map +1 -0
  287. package/src/lib/model/order-history.d.ts +58 -0
  288. package/src/lib/model/order-history.js +22 -0
  289. package/src/lib/model/order-history.js.map +1 -0
  290. package/src/lib/model/order-list-fields.d.ts +9 -1
  291. package/src/lib/model/order-list-fields.js +7 -1
  292. package/src/lib/model/order-list-fields.js.map +1 -1
  293. package/src/lib/model/order-shipping-export.d.ts +91 -0
  294. package/src/lib/model/order-shipping-export.js +192 -0
  295. package/src/lib/model/order-shipping-export.js.map +1 -0
  296. package/src/lib/model/order-status-view.d.ts +103 -0
  297. package/src/lib/model/order-status-view.js +156 -0
  298. package/src/lib/model/order-status-view.js.map +1 -0
  299. package/src/lib/model/order-webhooks.d.ts +142 -0
  300. package/src/lib/model/order-webhooks.js +91 -0
  301. package/src/lib/model/order-webhooks.js.map +1 -0
  302. package/src/lib/model/product-channel.d.ts +56 -0
  303. package/src/lib/model/product-channel.js +86 -0
  304. package/src/lib/model/product-channel.js.map +1 -0
  305. package/src/lib/model/product-modifiers.d.ts +80 -0
  306. package/src/lib/model/product-modifiers.js +140 -0
  307. package/src/lib/model/product-modifiers.js.map +1 -0
  308. package/src/lib/model/shippingeasy.d.ts +94 -0
  309. package/src/lib/model/shippingeasy.js +267 -0
  310. package/src/lib/model/shippingeasy.js.map +1 -0
  311. package/src/lib/model/shipstation.d.ts +125 -0
  312. package/src/lib/model/shipstation.js +399 -0
  313. package/src/lib/model/shipstation.js.map +1 -0
  314. package/src/lib/model/smart-collection-reads.d.ts +32 -0
  315. package/src/lib/model/smart-collection-reads.js +63 -0
  316. package/src/lib/model/smart-collection-reads.js.map +1 -0
  317. package/src/lib/model/tracking-url.d.ts +74 -0
  318. package/src/lib/model/tracking-url.js +159 -0
  319. package/src/lib/model/tracking-url.js.map +1 -0
  320. package/src/lib/plugin-config.d.ts +13 -0
  321. package/src/lib/plugin-config.js +77 -5
  322. package/src/lib/plugin-config.js.map +1 -1
  323. package/src/lib/plugin.js +23 -0
  324. package/src/lib/plugin.js.map +1 -1
  325. package/src/lib/pos-ops-config.d.ts +39 -0
  326. package/src/lib/pos-ops-config.js +88 -0
  327. package/src/lib/pos-ops-config.js.map +1 -0
  328. package/src/lib/printing/print-document.d.ts +106 -0
  329. package/src/lib/printing/print-document.js +464 -0
  330. package/src/lib/printing/print-document.js.map +1 -0
  331. package/src/lib/printing/product-labels.d.ts +58 -0
  332. package/src/lib/printing/product-labels.js +116 -0
  333. package/src/lib/printing/product-labels.js.map +1 -0
  334. package/src/lib/printing/render-epson.d.ts +57 -0
  335. package/src/lib/printing/render-epson.js +135 -0
  336. package/src/lib/printing/render-epson.js.map +1 -0
  337. package/src/lib/printing/render-star.d.ts +45 -0
  338. package/src/lib/printing/render-star.js +100 -0
  339. package/src/lib/printing/render-star.js.map +1 -0
  340. package/src/lib/printing/render-text.d.ts +25 -0
  341. package/src/lib/printing/render-text.js +53 -0
  342. package/src/lib/printing/render-text.js.map +1 -0
  343. package/src/lib/server/api-v1/openapi.js +27 -4
  344. package/src/lib/server/api-v1/openapi.js.map +1 -1
  345. package/src/lib/server/api-v1/order-view.d.ts +67 -0
  346. package/src/lib/server/api-v1/order-view.js +120 -0
  347. package/src/lib/server/api-v1/order-view.js.map +1 -0
  348. package/src/lib/server/api-v1/orders-and-products.js +58 -65
  349. package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
  350. package/src/lib/server/billing-webhook.js +135 -28
  351. package/src/lib/server/billing-webhook.js.map +1 -1
  352. package/src/lib/server/cancel-order.js +29 -0
  353. package/src/lib/server/cancel-order.js.map +1 -1
  354. package/src/lib/server/carrier-rates-availability.d.ts +26 -0
  355. package/src/lib/server/carrier-rates-availability.js +76 -0
  356. package/src/lib/server/carrier-rates-availability.js.map +1 -0
  357. package/src/lib/server/carrier-shipping.d.ts +84 -0
  358. package/src/lib/server/carrier-shipping.js +135 -0
  359. package/src/lib/server/carrier-shipping.js.map +1 -0
  360. package/src/lib/server/cart-checkout.d.ts +2 -0
  361. package/src/lib/server/cart-checkout.js +226 -22
  362. package/src/lib/server/cart-checkout.js.map +1 -1
  363. package/src/lib/server/checkout-extras.d.ts +64 -0
  364. package/src/lib/server/checkout-extras.js +157 -0
  365. package/src/lib/server/checkout-extras.js.map +1 -0
  366. package/src/lib/server/{feed.d.ts → checkout-status.d.ts} +2 -7
  367. package/src/lib/server/checkout-status.js +111 -0
  368. package/src/lib/server/checkout-status.js.map +1 -0
  369. package/src/lib/server/checkout.js +86 -9
  370. package/src/lib/server/checkout.js.map +1 -1
  371. package/src/lib/server/draft-order.js +34 -5
  372. package/src/lib/server/draft-order.js.map +1 -1
  373. package/src/lib/server/fulfill-order.d.ts +127 -10
  374. package/src/lib/server/fulfill-order.js +451 -49
  375. package/src/lib/server/fulfill-order.js.map +1 -1
  376. package/src/lib/server/legacy-feed.d.ts +28 -0
  377. package/src/lib/server/legacy-feed.js +52 -0
  378. package/src/lib/server/legacy-feed.js.map +1 -0
  379. package/src/lib/server/native-checkout.d.ts +34 -15
  380. package/src/lib/server/native-checkout.js +32 -17
  381. package/src/lib/server/native-checkout.js.map +1 -1
  382. package/src/lib/server/order-event-host-emit.d.ts +23 -0
  383. package/src/lib/server/order-event-host-emit.js +30 -0
  384. package/src/lib/server/order-event-host-emit.js.map +1 -0
  385. package/src/lib/server/order-event-triggers.d.ts +37 -0
  386. package/src/lib/server/order-event-triggers.js +119 -0
  387. package/src/lib/server/order-event-triggers.js.map +1 -0
  388. package/src/lib/server/order-events.d.ts +62 -0
  389. package/src/lib/server/order-events.js +109 -0
  390. package/src/lib/server/order-events.js.map +1 -0
  391. package/src/lib/server/order-history.d.ts +23 -0
  392. package/src/lib/server/order-history.js +65 -0
  393. package/src/lib/server/order-history.js.map +1 -0
  394. package/src/lib/server/order-notifications.d.ts +185 -0
  395. package/src/lib/server/order-notifications.js +567 -0
  396. package/src/lib/server/order-notifications.js.map +1 -0
  397. package/src/lib/server/order-receipt-send.d.ts +39 -0
  398. package/src/lib/server/order-receipt-send.js +151 -0
  399. package/src/lib/server/order-receipt-send.js.map +1 -0
  400. package/src/lib/server/order-status-token.d.ts +31 -0
  401. package/src/lib/server/order-status-token.js +75 -0
  402. package/src/lib/server/order-status-token.js.map +1 -0
  403. package/src/lib/server/order-status.d.ts +58 -0
  404. package/src/lib/server/order-status.js +141 -0
  405. package/src/lib/server/order-status.js.map +1 -0
  406. package/src/lib/server/order-webhooks.d.ts +108 -0
  407. package/src/lib/server/order-webhooks.js +622 -0
  408. package/src/lib/server/order-webhooks.js.map +1 -0
  409. package/src/lib/server/orders-shipping-prepare.d.ts +26 -0
  410. package/src/lib/server/orders-shipping-prepare.js +121 -0
  411. package/src/lib/server/orders-shipping-prepare.js.map +1 -0
  412. package/src/lib/server/payment-method-domains.d.ts +209 -0
  413. package/src/lib/server/payment-method-domains.js +444 -0
  414. package/src/lib/server/payment-method-domains.js.map +1 -0
  415. package/src/lib/server/payment-methods.d.ts +77 -0
  416. package/src/lib/server/payment-methods.js +284 -0
  417. package/src/lib/server/payment-methods.js.map +1 -0
  418. package/src/lib/server/pos-auth.d.ts +50 -0
  419. package/src/lib/server/pos-auth.js +121 -0
  420. package/src/lib/server/pos-auth.js.map +1 -0
  421. package/src/lib/server/pos-customer.d.ts +49 -0
  422. package/src/lib/server/pos-customer.js +257 -0
  423. package/src/lib/server/pos-customer.js.map +1 -0
  424. package/src/lib/server/pos-display.d.ts +57 -0
  425. package/src/lib/server/pos-display.js +419 -0
  426. package/src/lib/server/pos-display.js.map +1 -0
  427. package/src/lib/server/pos-fee-month.d.ts +34 -0
  428. package/src/lib/server/pos-fee-month.js +36 -0
  429. package/src/lib/server/pos-fee-month.js.map +1 -0
  430. package/src/lib/server/pos-ops-gate.d.ts +161 -0
  431. package/src/lib/server/pos-ops-gate.js +295 -0
  432. package/src/lib/server/pos-ops-gate.js.map +1 -0
  433. package/src/lib/server/pos-ops-routes.d.ts +22 -0
  434. package/src/lib/server/pos-ops-routes.js +36 -0
  435. package/src/lib/server/pos-ops-routes.js.map +1 -0
  436. package/src/lib/server/pos-order.d.ts +1 -18
  437. package/src/lib/server/pos-order.js +222 -42
  438. package/src/lib/server/pos-order.js.map +1 -1
  439. package/src/lib/server/pos-payment.d.ts +39 -0
  440. package/src/lib/server/pos-payment.js +922 -0
  441. package/src/lib/server/pos-payment.js.map +1 -0
  442. package/src/lib/server/pos-print.d.ts +82 -0
  443. package/src/lib/server/pos-print.js +193 -0
  444. package/src/lib/server/pos-print.js.map +1 -0
  445. package/src/lib/server/pos-readers.d.ts +27 -0
  446. package/src/lib/server/pos-readers.js +276 -0
  447. package/src/lib/server/pos-readers.js.map +1 -0
  448. package/src/lib/server/pos-refund-authority.d.ts +60 -0
  449. package/src/lib/server/pos-refund-authority.js +72 -0
  450. package/src/lib/server/pos-refund-authority.js.map +1 -0
  451. package/src/lib/server/pos-return.d.ts +58 -0
  452. package/src/lib/server/pos-return.js +891 -0
  453. package/src/lib/server/pos-return.js.map +1 -0
  454. package/src/lib/server/pos-sale-stamp.d.ts +66 -0
  455. package/src/lib/server/pos-sale-stamp.js +84 -0
  456. package/src/lib/server/pos-sale-stamp.js.map +1 -0
  457. package/src/lib/server/pos-sale.d.ts +170 -0
  458. package/src/lib/server/pos-sale.js +461 -0
  459. package/src/lib/server/pos-sale.js.map +1 -0
  460. package/src/lib/server/pos-shift.d.ts +45 -0
  461. package/src/lib/server/pos-shift.js +484 -0
  462. package/src/lib/server/pos-shift.js.map +1 -0
  463. package/src/lib/server/pos-staff-pin.d.ts +26 -0
  464. package/src/lib/server/pos-staff-pin.js +339 -0
  465. package/src/lib/server/pos-staff-pin.js.map +1 -0
  466. package/src/lib/server/pos-stripe.d.ts +91 -0
  467. package/src/lib/server/pos-stripe.js +129 -0
  468. package/src/lib/server/pos-stripe.js.map +1 -0
  469. package/src/lib/server/pos-terminal-connection-token.d.ts +48 -0
  470. package/src/lib/server/pos-terminal-connection-token.js +166 -0
  471. package/src/lib/server/pos-terminal-connection-token.js.map +1 -0
  472. package/src/lib/server/pos-terminal.d.ts +218 -0
  473. package/src/lib/server/pos-terminal.js +1014 -0
  474. package/src/lib/server/pos-terminal.js.map +1 -0
  475. package/src/lib/server/print-queue.d.ts +124 -0
  476. package/src/lib/server/print-queue.js +301 -0
  477. package/src/lib/server/print-queue.js.map +1 -0
  478. package/src/lib/server/printer-poll.d.ts +75 -0
  479. package/src/lib/server/printer-poll.js +325 -0
  480. package/src/lib/server/printer-poll.js.map +1 -0
  481. package/src/lib/server/printer-secret.d.ts +39 -0
  482. package/src/lib/server/printer-secret.js +56 -0
  483. package/src/lib/server/printer-secret.js.map +1 -0
  484. package/src/lib/server/printers.d.ts +114 -0
  485. package/src/lib/server/printers.js +546 -0
  486. package/src/lib/server/printers.js.map +1 -0
  487. package/src/lib/server/product-ai-capability.d.ts +42 -0
  488. package/src/lib/server/product-ai-capability.js +159 -0
  489. package/src/lib/server/product-ai-capability.js.map +1 -0
  490. package/src/lib/server/product-catalog.d.ts +42 -0
  491. package/src/lib/server/product-catalog.js +305 -0
  492. package/src/lib/server/product-catalog.js.map +1 -0
  493. package/src/lib/server/product-drafts.d.ts +119 -0
  494. package/src/lib/server/product-drafts.js +384 -0
  495. package/src/lib/server/product-drafts.js.map +1 -0
  496. package/src/lib/server/refund.js +110 -45
  497. package/src/lib/server/refund.js.map +1 -1
  498. package/src/lib/server/reserve.js +2 -0
  499. package/src/lib/server/reserve.js.map +1 -1
  500. package/src/lib/server/return-status-action.d.ts +37 -0
  501. package/src/lib/server/return-status-action.js +57 -0
  502. package/src/lib/server/return-status-action.js.map +1 -0
  503. package/src/lib/server/returns.d.ts +119 -0
  504. package/src/lib/server/returns.js +938 -0
  505. package/src/lib/server/returns.js.map +1 -0
  506. package/src/lib/server/shipment-records.d.ts +36 -0
  507. package/src/lib/server/shipment-records.js +289 -0
  508. package/src/lib/server/shipment-records.js.map +1 -0
  509. package/src/lib/server/shipping-connector-gates.d.ts +40 -0
  510. package/src/lib/server/shipping-connector-gates.js +97 -0
  511. package/src/lib/server/shipping-connector-gates.js.map +1 -0
  512. package/src/lib/server/shipping-connectors.d.ts +29 -0
  513. package/src/lib/server/shipping-connectors.js +236 -0
  514. package/src/lib/server/shipping-connectors.js.map +1 -0
  515. package/src/lib/server/shippingeasy.d.ts +238 -0
  516. package/src/lib/server/shippingeasy.js +787 -0
  517. package/src/lib/server/shippingeasy.js.map +1 -0
  518. package/src/lib/server/shipstation.d.ts +129 -0
  519. package/src/lib/server/shipstation.js +483 -0
  520. package/src/lib/server/shipstation.js.map +1 -0
  521. package/src/lib/server/site-page-resolver.d.ts +5 -0
  522. package/src/lib/server/site-page-resolver.js +156 -1
  523. package/src/lib/server/site-page-resolver.js.map +1 -1
  524. package/src/lib/server/stock-levels.d.ts +21 -0
  525. package/src/lib/server/stock-levels.js +263 -0
  526. package/src/lib/server/stock-levels.js.map +1 -0
  527. package/src/lib/server/stripe-refund.d.ts +47 -0
  528. package/src/lib/server/stripe-refund.js +87 -0
  529. package/src/lib/server/stripe-refund.js.map +1 -0
  530. package/src/lib/server/supplier-update.js +46 -5
  531. package/src/lib/server/supplier-update.js.map +1 -1
  532. package/src/lib/server/tax-engine-quote.d.ts +47 -0
  533. package/src/lib/server/tax-engine-quote.js +105 -0
  534. package/src/lib/server/tax-engine-quote.js.map +1 -0
  535. package/src/lib/server.js +146 -2
  536. package/src/lib/server.js.map +1 -1
  537. package/src/lib/site.js +12 -0
  538. package/src/lib/site.js.map +1 -1
  539. package/src/lib/subprocessors.d.ts +26 -0
  540. package/src/lib/subprocessors.js +50 -0
  541. package/src/lib/subprocessors.js.map +1 -0
  542. package/src/lib/tenant-emails.js +461 -3
  543. package/src/lib/tenant-emails.js.map +1 -1
  544. package/src/lib/testing/fake-firestore.d.ts +45 -0
  545. package/src/lib/testing/fake-firestore.js +189 -0
  546. package/src/lib/testing/fake-firestore.js.map +1 -0
  547. package/src/lib/testing/memory-firestore.d.ts +123 -0
  548. package/src/lib/testing/memory-firestore.js +274 -0
  549. package/src/lib/testing/memory-firestore.js.map +1 -0
  550. package/src/lib/testing/pos-ops-harness.d.ts +50 -0
  551. package/src/lib/testing/pos-ops-harness.js +184 -0
  552. package/src/lib/testing/pos-ops-harness.js.map +1 -0
  553. package/src/lib/testing/pos-ops-memory-firestore.d.ts +55 -0
  554. package/src/lib/testing/pos-ops-memory-firestore.js +376 -0
  555. package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -0
  556. package/src/lib/transfer/records-transfer.d.ts +11 -1
  557. package/src/lib/transfer/records-transfer.js +127 -5
  558. package/src/lib/transfer/records-transfer.js.map +1 -1
  559. package/src/lib/transfer/records.server.d.ts +9 -2
  560. package/src/lib/transfer/records.server.js +58 -7
  561. package/src/lib/transfer/records.server.js.map +1 -1
  562. package/src/lib/transfer/register-transfer-resources.js +40 -1
  563. package/src/lib/transfer/register-transfer-resources.js.map +1 -1
  564. package/src/lib/transfer/register-transfer-ui.js +4 -1
  565. package/src/lib/transfer/register-transfer-ui.js.map +1 -1
  566. package/src/lib/transfer/shipping-presets.d.ts +23 -0
  567. package/src/lib/transfer/shipping-presets.js +156 -0
  568. package/src/lib/transfer/shipping-presets.js.map +1 -0
  569. package/src/lib/transfer/tracking-transfer.d.ts +101 -0
  570. package/src/lib/transfer/tracking-transfer.js +546 -0
  571. package/src/lib/transfer/tracking-transfer.js.map +1 -0
  572. package/src/lib/transfer/tracking.server.d.ts +37 -0
  573. package/src/lib/transfer/tracking.server.js +393 -0
  574. package/src/lib/transfer/tracking.server.js.map +1 -0
  575. package/src/lib/transfer/transfer-keys.d.ts +2 -1
  576. package/src/lib/transfer/transfer-keys.js +6 -2
  577. package/src/lib/transfer/transfer-keys.js.map +1 -1
  578. package/src/lib/utils/code128.d.ts +37 -0
  579. package/src/lib/utils/code128.js +199 -0
  580. package/src/lib/utils/code128.js.map +1 -0
  581. package/src/lib/utils/order-invoice.d.ts +55 -0
  582. package/src/lib/utils/order-invoice.js +127 -0
  583. package/src/lib/utils/order-invoice.js.map +1 -0
  584. package/src/lib/utils/use-checkout-return-notice.d.ts +34 -0
  585. package/src/lib/utils/use-checkout-return-notice.js +78 -0
  586. package/src/lib/utils/use-checkout-return-notice.js.map +1 -0
  587. package/src/lib/utils/use-storefront-purchase-event.js +4 -0
  588. package/src/lib/utils/use-storefront-purchase-event.js.map +1 -1
  589. package/src/lib/server/feed.js +0 -69
  590. package/src/lib/server/feed.js.map +0 -1
@@ -0,0 +1,180 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { _ as _extends } from "@swc/helpers/_/_extends";
17
+ /** A money amount for print: `$12.50`, `-€3.00`. Locale is fixed so receipts read the same everywhere. */ export function formatReceiptMoney(cents, currency) {
18
+ const code = String(currency || 'usd').toUpperCase();
19
+ const safe = Number.isFinite(cents) ? Math.round(cents) : 0;
20
+ try {
21
+ var _resolvedOptions_maximumFractionDigits;
22
+ const digits = (_resolvedOptions_maximumFractionDigits = new Intl.NumberFormat('en-US', {
23
+ style: 'currency',
24
+ currency: code
25
+ }).resolvedOptions().maximumFractionDigits) != null ? _resolvedOptions_maximumFractionDigits : 2;
26
+ return new Intl.NumberFormat('en-US', {
27
+ style: 'currency',
28
+ currency: code,
29
+ minimumFractionDigits: digits,
30
+ maximumFractionDigits: digits
31
+ }).format(safe / 10 ** digits);
32
+ } catch (unused) {
33
+ return `${(safe / 100).toFixed(2)} ${code}`;
34
+ }
35
+ }
36
+ /** The receipt timestamp, e.g. `Oct 6, 2026, 3:04 PM`. */ export function formatReceiptTime(atMs, timeZone) {
37
+ const options = {
38
+ year: 'numeric',
39
+ month: 'short',
40
+ day: 'numeric',
41
+ hour: 'numeric',
42
+ minute: '2-digit'
43
+ };
44
+ try {
45
+ return new Intl.DateTimeFormat('en-US', _extends({}, options, {
46
+ timeZone: timeZone || 'UTC'
47
+ })).format(new Date(atMs));
48
+ } catch (unused) {
49
+ return new Intl.DateTimeFormat('en-US', _extends({}, options, {
50
+ timeZone: 'UTC'
51
+ })).format(new Date(atMs));
52
+ }
53
+ }
54
+ const PAYMENT_METHOD_LABELS = {
55
+ cash: 'Cash',
56
+ card_present: 'Card',
57
+ card_keyed: 'Card',
58
+ card_link: 'Card',
59
+ gift_card: 'Gift card',
60
+ folio: 'Charged to room'
61
+ };
62
+ const whole = (value)=>{
63
+ const number = Math.round(Number(value));
64
+ return Number.isFinite(number) && number > 0 ? number : 0;
65
+ };
66
+ /**
67
+ * The tenders an order was paid with: the register's payment ledger
68
+ * (`payments[]`, AGL-3607) when the order has one, otherwise a single tender
69
+ * read from the order itself (a cash sale's `changeCents`, a QR card sale).
70
+ */ export function receiptTendersFromOrder(order) {
71
+ var _order_totals;
72
+ const payments = Array.isArray(order['payments']) ? order['payments'] : [];
73
+ if (payments.length) {
74
+ let changeCents = 0;
75
+ let tipCents = 0;
76
+ const tenders = payments.filter((payment)=>payment && payment.status === 'succeeded').map((payment)=>{
77
+ changeCents += whole(payment.changeCents);
78
+ tipCents += whole(payment.tipCents);
79
+ const card = [
80
+ payment.cardBrand,
81
+ payment.last4 ? `**** ${payment.last4}` : ''
82
+ ].filter(Boolean).join(' ');
83
+ const label = card || PAYMENT_METHOD_LABELS[String(payment.method)] || 'Payment';
84
+ const tendered = whole(payment.cashTenderedCents);
85
+ return {
86
+ label,
87
+ amountCents: tendered || whole(payment.amountCents) + whole(payment.tipCents)
88
+ };
89
+ });
90
+ return {
91
+ tenders,
92
+ changeCents,
93
+ tipCents
94
+ };
95
+ }
96
+ const totalCents = whole((_order_totals = order.totals) == null ? void 0 : _order_totals.totalCents);
97
+ const changeCents = whole(order['changeCents']);
98
+ if (!totalCents) return {
99
+ tenders: [],
100
+ changeCents: 0,
101
+ tipCents: 0
102
+ };
103
+ const isCash = order.channel === 'pos' && !order.checkoutSessionId && !order.paymentIntentId;
104
+ return {
105
+ tenders: [
106
+ {
107
+ label: order['reservationId'] ? 'Charged to room' : isCash ? 'Cash' : 'Card',
108
+ amountCents: totalCents + (isCash ? changeCents : 0)
109
+ }
110
+ ],
111
+ changeCents: isCash ? changeCents : 0,
112
+ tipCents: 0
113
+ };
114
+ }
115
+ /** The receipt an order prints, from the order as stored. */ export function receiptDataFromOrder(orderId, order, context) {
116
+ var _order_lineItems, _ref, _ref1, _order_currency, _ref2;
117
+ var _context_storeLines;
118
+ const lines = ((_order_lineItems = order.lineItems) != null ? _order_lineItems : []).map((line)=>{
119
+ var _line_name;
120
+ const quantity = Math.max(1, Math.round(Number(line.quantity) || 1));
121
+ const unitCents = Math.round(Number(line.unitAmountCents) || 0);
122
+ return _extends({
123
+ name: String((_line_name = line.name) != null ? _line_name : 'Item')
124
+ }, line.variantLabel ? {
125
+ detail: String(line.variantLabel)
126
+ } : {}, {
127
+ quantity,
128
+ unitCents,
129
+ totalCents: unitCents * quantity
130
+ });
131
+ });
132
+ const totals = order.totals;
133
+ const subtotalCents = (_ref = totals == null ? void 0 : totals.itemsCents) != null ? _ref : lines.reduce((sum, line)=>sum + line.totalCents, 0);
134
+ const { tenders, changeCents, tipCents } = receiptTendersFromOrder(order);
135
+ const tip = whole(totals == null ? void 0 : totals.tipCents) || tipCents;
136
+ const orderNumber = order.number ? String(order.number) : orderId.slice(0, 8).toUpperCase();
137
+ return _extends({
138
+ storeName: context.storeName
139
+ }, ((_context_storeLines = context.storeLines) == null ? void 0 : _context_storeLines.length) ? {
140
+ storeLines: context.storeLines
141
+ } : {}, {
142
+ orderNumber,
143
+ orderId,
144
+ createdAtMs: Number(order['createdAtMs']) || Date.now()
145
+ }, context.timeZone ? {
146
+ timeZone: context.timeZone
147
+ } : {}, context.registerName ? {
148
+ registerName: context.registerName
149
+ } : {}, context.cashierName ? {
150
+ cashierName: context.cashierName
151
+ } : {}, {
152
+ currency: String((_ref1 = (_order_currency = order['currency']) != null ? _order_currency : context.currency) != null ? _ref1 : 'usd'),
153
+ lines,
154
+ subtotalCents
155
+ }, (totals == null ? void 0 : totals.discountCents) ? {
156
+ discountCents: totals.discountCents
157
+ } : {}, (totals == null ? void 0 : totals.shippingCents) ? {
158
+ shippingCents: totals.shippingCents
159
+ } : {}, (totals == null ? void 0 : totals.taxCents) ? {
160
+ taxCents: totals.taxCents
161
+ } : {}, tip ? {
162
+ tipCents: tip
163
+ } : {}, {
164
+ totalCents: (_ref2 = totals == null ? void 0 : totals.totalCents) != null ? _ref2 : subtotalCents
165
+ }, tenders.length ? {
166
+ tenders
167
+ } : {}, changeCents ? {
168
+ changeCents
169
+ } : {}, whole(order.refundedCents) ? {
170
+ refundedCents: whole(order.refundedCents)
171
+ } : {}, context.footer ? {
172
+ footer: context.footer
173
+ } : {}, {
174
+ barcode: orderNumber
175
+ }, context.banner ? {
176
+ banner: context.banner
177
+ } : {});
178
+ }
179
+
180
+ //# sourceMappingURL=commerce-receipt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/commerce-receipt.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { HostOrder } from './commerce-orders'\n\n/**\n * A receipt as DATA (AGL-3619), shared by every surface that prints one: the\n * cloud printer renderers (Star bytes, Epson ePOS-Print XML, plain text) and\n * the 80mm thermal receipt the register shows and prints from the browser\n * (AGL-3609). One model, so a reprint from the console, an auto-print on a\n * sale and the on-screen receipt cannot disagree about what was sold.\n *\n * Amounts are integer minor units in `currency`, and every label is already\n * the words to print: the renderers lay text out, they do not decide it.\n */\nexport interface ReceiptLine {\n name: string\n /** A variant label or SKU, printed under the name. */\n detail?: string\n quantity: number\n unitCents: number\n totalCents: number\n}\n\nexport interface ReceiptTender {\n /** e.g. `Cash`, `Visa •••• 4242`, `Gift card`. */\n label: string\n amountCents: number\n}\n\nexport interface ReceiptData {\n storeName: string\n /** Address, phone or website lines under the store name. */\n storeLines?: string[]\n /** The printable order number, e.g. `1042`. */\n orderNumber: string\n orderId?: string\n createdAtMs: number\n /** IANA zone the timestamp is printed in; UTC when absent. */\n timeZone?: string\n registerName?: string\n cashierName?: string\n /** ISO 4217, any case. */\n currency: string\n lines: ReceiptLine[]\n subtotalCents: number\n discountCents?: number\n shippingCents?: number\n taxCents?: number\n tipCents?: number\n totalCents: number\n tenders?: ReceiptTender[]\n changeCents?: number\n refundedCents?: number\n /** Printed small at the bottom: a returns policy, a thank-you. */\n footer?: string\n /** Code128 under the totals so a return can scan the order back up. Defaults to the order number. */\n barcode?: string\n /** `REPRINT` / `COPY` banner. */\n banner?: string\n}\n\n/** A money amount for print: `$12.50`, `-€3.00`. Locale is fixed so receipts read the same everywhere. */\nexport function formatReceiptMoney(cents: number, currency: string): string {\n const code = String(currency || 'usd').toUpperCase()\n const safe = Number.isFinite(cents) ? Math.round(cents) : 0\n try {\n const digits = new Intl.NumberFormat('en-US', { style: 'currency', currency: code })\n .resolvedOptions().maximumFractionDigits ?? 2\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: code,\n minimumFractionDigits: digits,\n maximumFractionDigits: digits,\n }).format(safe / 10 ** digits)\n } catch {\n return `${(safe / 100).toFixed(2)} ${code}`\n }\n}\n\n/** The receipt timestamp, e.g. `Oct 6, 2026, 3:04 PM`. */\nexport function formatReceiptTime(atMs: number, timeZone?: string): string {\n const options: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n }\n try {\n return new Intl.DateTimeFormat('en-US', { ...options, timeZone: timeZone || 'UTC' }).format(\n new Date(atMs),\n )\n } catch {\n return new Intl.DateTimeFormat('en-US', { ...options, timeZone: 'UTC' }).format(new Date(atMs))\n }\n}\n\nconst PAYMENT_METHOD_LABELS: Record<string, string> = {\n cash: 'Cash',\n card_present: 'Card',\n card_keyed: 'Card',\n card_link: 'Card',\n gift_card: 'Gift card',\n folio: 'Charged to room',\n}\n\nconst whole = (value: unknown): number => {\n const number = Math.round(Number(value))\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/**\n * The tenders an order was paid with: the register's payment ledger\n * (`payments[]`, AGL-3607) when the order has one, otherwise a single tender\n * read from the order itself (a cash sale's `changeCents`, a QR card sale).\n */\nexport function receiptTendersFromOrder(order: HostOrder & Record<string, any>): {\n tenders: ReceiptTender[]\n changeCents: number\n tipCents: number\n} {\n const payments: any[] = Array.isArray(order['payments']) ? order['payments'] : []\n if (payments.length) {\n let changeCents = 0\n let tipCents = 0\n const tenders = payments\n .filter((payment) => payment && payment.status === 'succeeded')\n .map((payment) => {\n changeCents += whole(payment.changeCents)\n tipCents += whole(payment.tipCents)\n const card = [payment.cardBrand, payment.last4 ? `**** ${payment.last4}` : '']\n .filter(Boolean)\n .join(' ')\n const label = card || PAYMENT_METHOD_LABELS[String(payment.method)] || 'Payment'\n const tendered = whole(payment.cashTenderedCents)\n return {\n label,\n amountCents: tendered || whole(payment.amountCents) + whole(payment.tipCents),\n }\n })\n return { tenders, changeCents, tipCents }\n }\n const totalCents = whole(order.totals?.totalCents)\n const changeCents = whole(order['changeCents'])\n if (!totalCents) return { tenders: [], changeCents: 0, tipCents: 0 }\n const isCash = order.channel === 'pos' && !order.checkoutSessionId && !order.paymentIntentId\n return {\n tenders: [\n {\n label: order['reservationId'] ? 'Charged to room' : isCash ? 'Cash' : 'Card',\n amountCents: totalCents + (isCash ? changeCents : 0),\n },\n ],\n changeCents: isCash ? changeCents : 0,\n tipCents: 0,\n }\n}\n\nexport interface ReceiptContext {\n storeName: string\n storeLines?: string[]\n registerName?: string\n cashierName?: string\n timeZone?: string\n currency?: string\n footer?: string\n banner?: string\n}\n\n/** The receipt an order prints, from the order as stored. */\nexport function receiptDataFromOrder(\n orderId: string,\n order: HostOrder & Record<string, any>,\n context: ReceiptContext,\n): ReceiptData {\n const lines: ReceiptLine[] = (order.lineItems ?? []).map((line) => {\n const quantity = Math.max(1, Math.round(Number(line.quantity) || 1))\n const unitCents = Math.round(Number(line.unitAmountCents) || 0)\n return {\n name: String(line.name ?? 'Item'),\n ...(line.variantLabel ? { detail: String(line.variantLabel) } : {}),\n quantity,\n unitCents,\n totalCents: unitCents * quantity,\n }\n })\n const totals = order.totals\n const subtotalCents = totals?.itemsCents ?? lines.reduce((sum, line) => sum + line.totalCents, 0)\n const { tenders, changeCents, tipCents } = receiptTendersFromOrder(order)\n const tip = whole((totals as any)?.tipCents) || tipCents\n const orderNumber = order.number ? String(order.number) : orderId.slice(0, 8).toUpperCase()\n return {\n storeName: context.storeName,\n ...(context.storeLines?.length ? { storeLines: context.storeLines } : {}),\n orderNumber,\n orderId,\n createdAtMs: Number(order['createdAtMs']) || Date.now(),\n ...(context.timeZone ? { timeZone: context.timeZone } : {}),\n ...(context.registerName ? { registerName: context.registerName } : {}),\n ...(context.cashierName ? { cashierName: context.cashierName } : {}),\n currency: String(order['currency'] ?? context.currency ?? 'usd'),\n lines,\n subtotalCents,\n ...(totals?.discountCents ? { discountCents: totals.discountCents } : {}),\n ...(totals?.shippingCents ? { shippingCents: totals.shippingCents } : {}),\n ...(totals?.taxCents ? { taxCents: totals.taxCents } : {}),\n ...(tip ? { tipCents: tip } : {}),\n totalCents: totals?.totalCents ?? subtotalCents,\n ...(tenders.length ? { tenders } : {}),\n ...(changeCents ? { changeCents } : {}),\n ...(whole(order.refundedCents) ? { refundedCents: whole(order.refundedCents) } : {}),\n ...(context.footer ? { footer: context.footer } : {}),\n barcode: orderNumber,\n ...(context.banner ? { banner: context.banner } : {}),\n }\n}\n"],"names":["formatReceiptMoney","cents","currency","code","String","toUpperCase","safe","Number","isFinite","Math","round","digits","Intl","NumberFormat","style","resolvedOptions","maximumFractionDigits","minimumFractionDigits","format","toFixed","formatReceiptTime","atMs","timeZone","options","year","month","day","hour","minute","DateTimeFormat","Date","PAYMENT_METHOD_LABELS","cash","card_present","card_keyed","card_link","gift_card","folio","whole","value","number","receiptTendersFromOrder","order","payments","Array","isArray","length","changeCents","tipCents","tenders","filter","payment","status","map","card","cardBrand","last4","Boolean","join","label","method","tendered","cashTenderedCents","amountCents","totalCents","totals","isCash","channel","checkoutSessionId","paymentIntentId","receiptDataFromOrder","orderId","context","lines","lineItems","line","quantity","max","unitCents","unitAmountCents","name","variantLabel","detail","subtotalCents","itemsCents","reduce","sum","tip","orderNumber","slice","storeName","storeLines","createdAtMs","now","registerName","cashierName","discountCents","shippingCents","taxCents","refundedCents","footer","barcode","banner"],"mappings":"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"}
@@ -0,0 +1,207 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { ProductType } from './commerce';
18
+ import { type HostOrder } from './commerce-orders';
19
+ /**
20
+ * Returns (RMA, AGL-3611): `hosts/{hostId}/returns/{id}`.
21
+ *
22
+ * A buyer asks to send items back, from their account or the order-status
23
+ * page; the merchant approves or declines, receives the parcel and decides
24
+ * per line whether it goes back on the shelf, then refunds through the
25
+ * order's own refund route. The return is the record of all of that, so the
26
+ * order keeps meaning what it always meant and the money still moves through
27
+ * the one door that guards it.
28
+ *
29
+ * Every rule here is pure and shared by the buyer's route, the merchant's
30
+ * route and the console, so the three cannot disagree about what is
31
+ * returnable.
32
+ */
33
+ export type ReturnStatus = 'requested' | 'approved' | 'declined' | 'received' | 'refunded' | 'closed';
34
+ export declare const RETURN_STATUSES: readonly ReturnStatus[];
35
+ export declare const RETURN_STATUS_LABELS: Record<ReturnStatus, string>;
36
+ export declare const RETURN_STATUS_COLOR: Record<ReturnStatus, 'default' | 'info' | 'warning' | 'success' | 'error'>;
37
+ export type ReturnReason = 'damaged' | 'wrong_item' | 'not_as_described' | 'size_or_fit' | 'no_longer_needed' | 'other';
38
+ export declare const RETURN_REASON_LABELS: Record<ReturnReason, string>;
39
+ export declare const RETURN_REASONS: ReturnReason[];
40
+ export interface ReturnLine {
41
+ lineItemId: number;
42
+ quantity: number;
43
+ reason: ReturnReason;
44
+ /** The line's name when the return was opened, for lists that read no order. */
45
+ name?: string;
46
+ }
47
+ /** A return label a shipping plugin bought for the buyer to send the parcel with. */
48
+ export interface ReturnLabel {
49
+ carrier: string;
50
+ trackingNumber: string;
51
+ labelUrl: string;
52
+ trackingUrl?: string;
53
+ attachedAtMs: number;
54
+ }
55
+ /** What went back on the shelf when the parcel arrived. */
56
+ export interface ReturnRestock {
57
+ lines: Array<{
58
+ lineItemId: number;
59
+ quantity: number;
60
+ }>;
61
+ /** The stock location the units went to, for a multi-location store. */
62
+ locationId?: string;
63
+ atMs: number;
64
+ }
65
+ export interface ReturnTimelineEvent {
66
+ atMs: number;
67
+ event: string;
68
+ detail?: string;
69
+ }
70
+ /** `hosts/{hostId}/returns/{id}`, written only by the server. */
71
+ export interface HostReturn {
72
+ orderId: string;
73
+ /** The order's number, for the list, e.g. `#1042`. */
74
+ orderNumber: string;
75
+ customerEmail: string | null;
76
+ customerName: string | null;
77
+ lines: ReturnLine[];
78
+ status: ReturnStatus;
79
+ /** Who opened it: the buyer, or the merchant on their behalf. */
80
+ requestedBy: 'buyer' | 'merchant';
81
+ /**
82
+ * `register` for a return taken and refunded at a POS register (AGL-3609):
83
+ * it is created already `refunded`, and the register's own record under
84
+ * `registers/{registerId}/returns` holds the tenders it went back to.
85
+ */
86
+ source?: 'register';
87
+ registerId?: string;
88
+ customerNote?: string;
89
+ merchantNote?: string;
90
+ returnLabel?: ReturnLabel;
91
+ restock?: ReturnRestock;
92
+ /** When the refund went through the order's refund route, and for how much. */
93
+ refundedAtMs?: number;
94
+ refundCents?: number;
95
+ timeline: ReturnTimelineEvent[];
96
+ createdAtMs: number;
97
+ updatedAtMs: number;
98
+ }
99
+ /** The store's return policy, at `hosts/{hostId}/settings/store` `returns`. */
100
+ export interface StoreReturnSettings {
101
+ /** Whether buyers may ask for a return themselves. */
102
+ enabled: boolean;
103
+ /** Days after the order shipped (or was placed, if it never shipped). */
104
+ windowDays: number;
105
+ /** The product types a buyer may return. */
106
+ eligibleTypes: ProductType[];
107
+ }
108
+ export declare const DEFAULT_RETURN_SETTINGS: StoreReturnSettings;
109
+ /** The most days a window may be set to, and the most a note may hold. */
110
+ export declare const RETURN_WINDOW_MAX_DAYS = 365;
111
+ export declare const RETURN_NOTE_MAX = 1000;
112
+ /** The stored settings, read defensively: the document is admin-writable. */
113
+ export declare function readReturnSettings(raw: unknown): StoreReturnSettings;
114
+ /** The return state machine. */
115
+ export declare function canTransitionReturn(from: ReturnStatus, to: ReturnStatus): boolean;
116
+ /** Whether a return still holds units against the order. */
117
+ export declare function returnIsOpen(entry: Pick<HostReturn, 'status'>): boolean;
118
+ /** Whether a return is still holding units, or took them: anything not declined. */
119
+ export declare function returnHoldsUnits(entry: Pick<HostReturn, 'status' | 'refundedAtMs'>): boolean;
120
+ /** Units each line could be sent back, and why not where none can. */
121
+ export interface ReturnableLine {
122
+ lineItemId: number;
123
+ name: string;
124
+ variantLabel: string | null;
125
+ productType: ProductType | null;
126
+ /** Units the buyer has and may send back. */
127
+ returnable: number;
128
+ /** Why `returnable` is 0, in the buyer's words; `null` when it is not. */
129
+ blocked: string | null;
130
+ }
131
+ /**
132
+ * What can come back on an order: each line's shipped units (every unit, for
133
+ * a line with nothing to ship), less units already in a return that has not
134
+ * been declined, less everything on a line already refunded by name.
135
+ */
136
+ export declare function returnableLines(order: Pick<HostOrder, 'lineItems' | 'fulfillments' | 'refundedLineItemIds'>, existing: ReadonlyArray<Pick<HostReturn, 'status' | 'lines' | 'refundedAtMs'>>, settings: Pick<StoreReturnSettings, 'eligibleTypes'> | null): ReturnableLine[];
137
+ /**
138
+ * When the return window closes: `windowDays` after the latest shipment, or
139
+ * after the order was placed when nothing shipped (a digital order). `null`
140
+ * when the order carries no date at all, which reads as open.
141
+ */
142
+ export declare function returnWindowEndsAtMs(order: Pick<HostOrder, 'fulfillments' | 'createdAtMs'>, settings: Pick<StoreReturnSettings, 'windowDays'>): number | null;
143
+ /** Why a requested return was refused. */
144
+ export type ReturnRequestProblem = {
145
+ problem: 'disabled';
146
+ } | {
147
+ problem: 'window_closed';
148
+ endedAtMs: number;
149
+ } | {
150
+ problem: 'order_status';
151
+ status: string;
152
+ } | {
153
+ problem: 'empty';
154
+ } | {
155
+ problem: 'bad_line';
156
+ lineItemId: number;
157
+ } | {
158
+ problem: 'bad_reason';
159
+ lineItemId: number;
160
+ } | {
161
+ problem: 'too_many';
162
+ lineItemId: number;
163
+ returnable: number;
164
+ };
165
+ /** Order statuses a return may be opened against. */
166
+ export declare const RETURNABLE_ORDER_STATUSES: readonly string[];
167
+ /**
168
+ * Checks a return request against the order and the returns already open on
169
+ * it, merging duplicate lines first. `merchant` skips the buyer-only rules —
170
+ * the switch and the window — since a merchant may take anything back.
171
+ */
172
+ export declare function validateReturnRequest(input: {
173
+ order: Pick<HostOrder, 'status' | 'lineItems' | 'fulfillments' | 'refundedLineItemIds' | 'createdAtMs'>;
174
+ existing: ReadonlyArray<Pick<HostReturn, 'status' | 'lines' | 'refundedAtMs'>>;
175
+ settings: StoreReturnSettings;
176
+ lines: ReadonlyArray<{
177
+ lineItemId: unknown;
178
+ quantity: unknown;
179
+ reason: unknown;
180
+ }>;
181
+ by: 'buyer' | 'merchant';
182
+ now: number;
183
+ }): {
184
+ lines: ReturnLine[];
185
+ } | ReturnRequestProblem;
186
+ /** Words for a refused request, for the buyer and the merchant alike. */
187
+ export declare function describeReturnRequestProblem(problem: ReturnRequestProblem): string;
188
+ /**
189
+ * What refunding a return's units is worth: each line's paid share
190
+ * (`orderLineRefundCents`, discount apportioned) in proportion to the units
191
+ * coming back, never more than is left to refund on the order. Shipping and
192
+ * tax stay out, as they do for a line refund; the merchant may add them by
193
+ * amount.
194
+ */
195
+ export declare function returnRefundCents(order: Pick<HostOrder, 'lineItems' | 'totals' | 'refundedCents' | 'amountCents'>, lines: ReadonlyArray<Pick<ReturnLine, 'lineItemId' | 'quantity'>>): number;
196
+ /**
197
+ * The lines a return can refund BY NAME: those it takes back in full, which
198
+ * the refund route then withdraws entitlements for. A partial-quantity line is
199
+ * refunded by amount alone.
200
+ */
201
+ export declare function returnWholeLineIds(order: Pick<HostOrder, 'lineItems'>, lines: ReadonlyArray<Pick<ReturnLine, 'lineItemId' | 'quantity'>>): number[];
202
+ /** A short "2× Mug, 1× Shirt" for a return's lines. */
203
+ export declare function describeReturnLines(order: Pick<HostOrder, 'lineItems'>, lines: ReadonlyArray<Pick<ReturnLine, 'lineItemId' | 'quantity'>>): string;
204
+ /** The order number a return lists by. */
205
+ export declare function returnOrderNumber(order: Pick<HostOrder, 'number'>, orderId: string): string;
206
+ /** Appends a return timeline event immutably. */
207
+ export declare function appendReturnEvent(entry: Pick<HostReturn, 'timeline'>, event: string, detail?: string, atMs?: number): ReturnTimelineEvent[];