@aglyn/plugins-commerce 1.0.0-beta.230 → 1.0.0-beta.232

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 (609) 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/catalog-organization-card.component.js +1 -0
  39. package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
  40. package/src/lib/components/console/customer-notifications-card.component.d.ts +19 -0
  41. package/src/lib/components/console/customer-notifications-card.component.js +149 -0
  42. package/src/lib/components/console/customer-notifications-card.component.js.map +1 -0
  43. package/src/lib/components/console/host-orders-card.component.js +88 -6
  44. package/src/lib/components/console/host-orders-card.component.js.map +1 -1
  45. package/src/lib/components/console/locations-card.component.js +164 -57
  46. package/src/lib/components/console/locations-card.component.js.map +1 -1
  47. package/src/lib/components/console/order-detail-dialog.component.js +209 -61
  48. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
  49. package/src/lib/components/console/order-fulfillment-panel.component.d.ts +48 -0
  50. package/src/lib/components/console/order-fulfillment-panel.component.js +542 -0
  51. package/src/lib/components/console/order-fulfillment-panel.component.js.map +1 -0
  52. package/src/lib/components/console/order-invoice.component.d.ts +33 -0
  53. package/src/lib/components/console/order-invoice.component.js +81 -0
  54. package/src/lib/components/console/order-invoice.component.js.map +1 -0
  55. package/src/lib/components/console/order-receipt-resend.component.d.ts +21 -0
  56. package/src/lib/components/console/order-receipt-resend.component.js +203 -0
  57. package/src/lib/components/console/order-receipt-resend.component.js.map +1 -0
  58. package/src/lib/components/console/order-returns.component.d.ts +36 -0
  59. package/src/lib/components/console/order-returns.component.js +142 -0
  60. package/src/lib/components/console/order-returns.component.js.map +1 -0
  61. package/src/lib/components/console/order-shipping-actions.component.d.ts +54 -0
  62. package/src/lib/components/console/order-shipping-actions.component.js +149 -0
  63. package/src/lib/components/console/order-shipping-actions.component.js.map +1 -0
  64. package/src/lib/components/console/order-webhooks-card.component.d.ts +50 -0
  65. package/src/lib/components/console/order-webhooks-card.component.js +623 -0
  66. package/src/lib/components/console/order-webhooks-card.component.js.map +1 -0
  67. package/src/lib/components/console/order-zones.d.ts +155 -0
  68. package/src/lib/components/console/order-zones.js +40 -0
  69. package/src/lib/components/console/order-zones.js.map +1 -0
  70. package/src/lib/components/console/payment-methods-card.component.d.ts +67 -0
  71. package/src/lib/components/console/payment-methods-card.component.js +395 -0
  72. package/src/lib/components/console/payment-methods-card.component.js.map +1 -0
  73. package/src/lib/components/console/pos/pos-api.d.ts +124 -0
  74. package/src/lib/components/console/pos/pos-api.js +101 -0
  75. package/src/lib/components/console/pos/pos-api.js.map +1 -0
  76. package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +36 -0
  77. package/src/lib/components/console/pos/pos-cart-panel.component.js +160 -0
  78. package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -0
  79. package/src/lib/components/console/pos/pos-item-dialog.component.d.ts +39 -0
  80. package/src/lib/components/console/pos/pos-item-dialog.component.js +352 -0
  81. package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -0
  82. package/src/lib/components/console/pos/pos-product-grid.component.d.ts +47 -0
  83. package/src/lib/components/console/pos/pos-product-grid.component.js +272 -0
  84. package/src/lib/components/console/pos/pos-product-grid.component.js.map +1 -0
  85. package/src/lib/components/console/pos/pos-receipt-panel.component.d.ts +27 -0
  86. package/src/lib/components/console/pos/pos-receipt-panel.component.js +282 -0
  87. package/src/lib/components/console/pos/pos-receipt-panel.component.js.map +1 -0
  88. package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +53 -0
  89. package/src/lib/components/console/pos/pos-tender-dialogs.component.js +445 -0
  90. package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -0
  91. package/src/lib/components/console/pos/pos-tender-panel.component.d.ts +31 -0
  92. package/src/lib/components/console/pos/pos-tender-panel.component.js +640 -0
  93. package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -0
  94. package/src/lib/components/console/pos/use-pos-display.d.ts +43 -0
  95. package/src/lib/components/console/pos/use-pos-display.js +161 -0
  96. package/src/lib/components/console/pos/use-pos-display.js.map +1 -0
  97. package/src/lib/components/console/pos-devices-card.component.d.ts +14 -0
  98. package/src/lib/components/console/pos-devices-card.component.js +546 -0
  99. package/src/lib/components/console/pos-devices-card.component.js.map +1 -0
  100. package/src/lib/components/console/pos-display/brand-screen.d.ts +33 -0
  101. package/src/lib/components/console/pos-display/brand-screen.js +85 -0
  102. package/src/lib/components/console/pos-display/brand-screen.js.map +1 -0
  103. package/src/lib/components/console/pos-display/cart-screen.d.ts +29 -0
  104. package/src/lib/components/console/pos-display/cart-screen.js +166 -0
  105. package/src/lib/components/console/pos-display/cart-screen.js.map +1 -0
  106. package/src/lib/components/console/pos-display/pairing-screen.d.ts +24 -0
  107. package/src/lib/components/console/pos-display/pairing-screen.js +127 -0
  108. package/src/lib/components/console/pos-display/pairing-screen.js.map +1 -0
  109. package/src/lib/components/console/pos-display/pos-display-api.d.ts +90 -0
  110. package/src/lib/components/console/pos-display/pos-display-api.js +140 -0
  111. package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -0
  112. package/src/lib/components/console/pos-display/receipt-screen.d.ts +35 -0
  113. package/src/lib/components/console/pos-display/receipt-screen.js +200 -0
  114. package/src/lib/components/console/pos-display/receipt-screen.js.map +1 -0
  115. package/src/lib/components/console/pos-display/tip-screen.d.ts +36 -0
  116. package/src/lib/components/console/pos-display/tip-screen.js +211 -0
  117. package/src/lib/components/console/pos-display/tip-screen.js.map +1 -0
  118. package/src/lib/components/console/pos-display-page.component.d.ts +16 -0
  119. package/src/lib/components/console/pos-display-page.component.js +407 -0
  120. package/src/lib/components/console/pos-display-page.component.js.map +1 -0
  121. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.d.ts +40 -0
  122. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js +289 -0
  123. package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js.map +1 -0
  124. package/src/lib/components/console/pos-ops/pos-last-receipt.component.d.ts +34 -0
  125. package/src/lib/components/console/pos-ops/pos-last-receipt.component.js +61 -0
  126. package/src/lib/components/console/pos-ops/pos-last-receipt.component.js.map +1 -0
  127. package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +38 -0
  128. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +129 -0
  129. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -0
  130. package/src/lib/components/console/pos-ops/pos-ops-api.d.ts +37 -0
  131. package/src/lib/components/console/pos-ops/pos-ops-api.js +60 -0
  132. package/src/lib/components/console/pos-ops/pos-ops-api.js.map +1 -0
  133. package/src/lib/components/console/pos-ops/pos-pin-pad.component.d.ts +48 -0
  134. package/src/lib/components/console/pos-ops/pos-pin-pad.component.js +220 -0
  135. package/src/lib/components/console/pos-ops/pos-pin-pad.component.js.map +1 -0
  136. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.d.ts +63 -0
  137. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js +186 -0
  138. package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js.map +1 -0
  139. package/src/lib/components/console/pos-ops/pos-receipt.d.ts +39 -0
  140. package/src/lib/components/console/pos-ops/pos-receipt.js +182 -0
  141. package/src/lib/components/console/pos-ops/pos-receipt.js.map +1 -0
  142. package/src/lib/components/console/pos-ops/pos-return-dialog.component.d.ts +40 -0
  143. package/src/lib/components/console/pos-ops/pos-return-dialog.component.js +465 -0
  144. package/src/lib/components/console/pos-ops/pos-return-dialog.component.js.map +1 -0
  145. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.d.ts +29 -0
  146. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js +253 -0
  147. package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js.map +1 -0
  148. package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +34 -0
  149. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +494 -0
  150. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -0
  151. package/src/lib/components/console/pos-ops/pos-shift-report.component.d.ts +37 -0
  152. package/src/lib/components/console/pos-ops/pos-shift-report.component.js +102 -0
  153. package/src/lib/components/console/pos-ops/pos-shift-report.component.js.map +1 -0
  154. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.d.ts +30 -0
  155. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js +277 -0
  156. package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js.map +1 -0
  157. package/src/lib/components/console/pos-ops/register-ops.d.ts +28 -0
  158. package/src/lib/components/console/pos-ops/register-ops.js +28 -0
  159. package/src/lib/components/console/pos-ops/register-ops.js.map +1 -0
  160. package/src/lib/components/console/pos-ops/use-pos-cashier.d.ts +46 -0
  161. package/src/lib/components/console/pos-ops/use-pos-cashier.js +128 -0
  162. package/src/lib/components/console/pos-ops/use-pos-cashier.js.map +1 -0
  163. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.d.ts +36 -0
  164. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js +64 -0
  165. package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js.map +1 -0
  166. package/src/lib/components/console/pos-page.component.d.ts +13 -5
  167. package/src/lib/components/console/pos-page.component.js +756 -654
  168. package/src/lib/components/console/pos-page.component.js.map +1 -1
  169. package/src/lib/components/console/pos-zones.d.ts +23 -0
  170. package/src/lib/components/console/pos-zones.js +31 -0
  171. package/src/lib/components/console/pos-zones.js.map +1 -0
  172. package/src/lib/components/console/product-editor-dialog.component.js +61 -71
  173. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  174. package/src/lib/components/console/product-labels-dialog.component.d.ts +13 -0
  175. package/src/lib/components/console/product-labels-dialog.component.js +197 -0
  176. package/src/lib/components/console/product-labels-dialog.component.js.map +1 -0
  177. package/src/lib/components/console/product-register-fields.component.d.ts +19 -0
  178. package/src/lib/components/console/product-register-fields.component.js +241 -0
  179. package/src/lib/components/console/product-register-fields.component.js.map +1 -0
  180. package/src/lib/components/console/product-zones.d.ts +44 -0
  181. package/src/lib/components/console/product-zones.js.map +1 -1
  182. package/src/lib/components/console/products-hub-card.component.js +23 -20
  183. package/src/lib/components/console/products-hub-card.component.js.map +1 -1
  184. package/src/lib/components/console/register-hardware-card.component.d.ts +33 -0
  185. package/src/lib/components/console/register-hardware-card.component.js +826 -0
  186. package/src/lib/components/console/register-hardware-card.component.js.map +1 -0
  187. package/src/lib/components/console/registers-card.component.js +24 -5
  188. package/src/lib/components/console/registers-card.component.js.map +1 -1
  189. package/src/lib/components/console/return-actions.d.ts +38 -0
  190. package/src/lib/components/console/return-actions.js +76 -0
  191. package/src/lib/components/console/return-actions.js.map +1 -0
  192. package/src/lib/components/console/return-detail-dialog.component.d.ts +34 -0
  193. package/src/lib/components/console/return-detail-dialog.component.js +718 -0
  194. package/src/lib/components/console/return-detail-dialog.component.js.map +1 -0
  195. package/src/lib/components/console/return-settings-card.component.d.ts +34 -0
  196. package/src/lib/components/console/return-settings-card.component.js +195 -0
  197. package/src/lib/components/console/return-settings-card.component.js.map +1 -0
  198. package/src/lib/components/console/return-zones.d.ts +87 -0
  199. package/src/lib/components/console/return-zones.js +31 -0
  200. package/src/lib/components/console/return-zones.js.map +1 -0
  201. package/src/lib/components/console/returns-card.component.d.ts +45 -0
  202. package/src/lib/components/console/returns-card.component.js +159 -0
  203. package/src/lib/components/console/returns-card.component.js.map +1 -0
  204. package/src/lib/components/console/shipping-settings-card.component.js +161 -5
  205. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
  206. package/src/lib/components/console/shippingeasy-card.component.d.ts +59 -0
  207. package/src/lib/components/console/shippingeasy-card.component.js +378 -0
  208. package/src/lib/components/console/shippingeasy-card.component.js.map +1 -0
  209. package/src/lib/components/console/shipstation-card.component.d.ts +35 -0
  210. package/src/lib/components/console/shipstation-card.component.js +345 -0
  211. package/src/lib/components/console/shipstation-card.component.js.map +1 -0
  212. package/src/lib/components/console/start-return-dialog.component.d.ts +40 -0
  213. package/src/lib/components/console/start-return-dialog.component.js +243 -0
  214. package/src/lib/components/console/start-return-dialog.component.js.map +1 -0
  215. package/src/lib/components/console/stock-movements-card.component.js +2 -1
  216. package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
  217. package/src/lib/components/console/store-settings-card.component.js +2 -66
  218. package/src/lib/components/console/store-settings-card.component.js.map +1 -1
  219. package/src/lib/components/console/store-zones.d.ts +42 -0
  220. package/src/lib/components/console/store-zones.js +39 -0
  221. package/src/lib/components/console/store-zones.js.map +1 -0
  222. package/src/lib/components/console/storefront-tax-summary-card.component.js +1 -0
  223. package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -1
  224. package/src/lib/components/order-status.d.ts +36 -0
  225. package/src/lib/components/order-status.js +502 -0
  226. package/src/lib/components/order-status.js.map +1 -0
  227. package/src/lib/components/product-detail.js +41 -2
  228. package/src/lib/components/product-detail.js.map +1 -1
  229. package/src/lib/components/return-request.d.ts +32 -0
  230. package/src/lib/components/return-request.js +576 -0
  231. package/src/lib/components/return-request.js.map +1 -0
  232. package/src/lib/components/storefront-payment-appearance.d.ts +32 -0
  233. package/src/lib/components/storefront-payment-appearance.js +114 -0
  234. package/src/lib/components/storefront-payment-appearance.js.map +1 -0
  235. package/src/lib/components/storefront-payment-element.d.ts +57 -1
  236. package/src/lib/components/storefront-payment-element.js +332 -33
  237. package/src/lib/components/storefront-payment-element.js.map +1 -1
  238. package/src/lib/constants/order-status.d.ts +22 -0
  239. package/src/lib/constants/order-status.js +22 -0
  240. package/src/lib/constants/order-status.js.map +1 -0
  241. package/src/lib/constants/return-request.d.ts +27 -0
  242. package/src/lib/constants/return-request.js +32 -0
  243. package/src/lib/constants/return-request.js.map +1 -0
  244. package/src/lib/constants/stock-movement-query.js +2 -1
  245. package/src/lib/constants/stock-movement-query.js.map +1 -1
  246. package/src/lib/declarations.console-server.js +9 -0
  247. package/src/lib/declarations.console-server.js.map +1 -1
  248. package/src/lib/declarations.server.d.ts +2 -1
  249. package/src/lib/declarations.server.js +68 -1
  250. package/src/lib/declarations.server.js.map +1 -1
  251. package/src/lib/model/buyer-notifications.d.ts +59 -0
  252. package/src/lib/model/buyer-notifications.js +97 -0
  253. package/src/lib/model/buyer-notifications.js.map +1 -0
  254. package/src/lib/model/commerce-orders.d.ts +171 -2
  255. package/src/lib/model/commerce-orders.js +26 -16
  256. package/src/lib/model/commerce-orders.js.map +1 -1
  257. package/src/lib/model/commerce-payment-methods.d.ts +146 -0
  258. package/src/lib/model/commerce-payment-methods.js +247 -0
  259. package/src/lib/model/commerce-payment-methods.js.map +1 -0
  260. package/src/lib/model/commerce-pos-ops.d.ts +437 -0
  261. package/src/lib/model/commerce-pos-ops.js +721 -0
  262. package/src/lib/model/commerce-pos-ops.js.map +1 -0
  263. package/src/lib/model/commerce-pos.d.ts +263 -0
  264. package/src/lib/model/commerce-pos.js +375 -0
  265. package/src/lib/model/commerce-pos.js.map +1 -0
  266. package/src/lib/model/commerce-printers.d.ts +211 -0
  267. package/src/lib/model/commerce-printers.js +181 -0
  268. package/src/lib/model/commerce-printers.js.map +1 -0
  269. package/src/lib/model/commerce-receipt.d.ts +97 -0
  270. package/src/lib/model/commerce-receipt.js +180 -0
  271. package/src/lib/model/commerce-receipt.js.map +1 -0
  272. package/src/lib/model/commerce-returns.d.ts +207 -0
  273. package/src/lib/model/commerce-returns.js +300 -0
  274. package/src/lib/model/commerce-returns.js.map +1 -0
  275. package/src/lib/model/commerce-shipping.d.ts +44 -1
  276. package/src/lib/model/commerce-shipping.js +53 -9
  277. package/src/lib/model/commerce-shipping.js.map +1 -1
  278. package/src/lib/model/commerce-tax-engine.d.ts +90 -0
  279. package/src/lib/model/commerce-tax-engine.js +129 -0
  280. package/src/lib/model/commerce-tax-engine.js.map +1 -0
  281. package/src/lib/model/commerce.d.ts +91 -2
  282. package/src/lib/model/commerce.js +89 -1
  283. package/src/lib/model/commerce.js.map +1 -1
  284. package/src/lib/model/index.d.ts +16 -0
  285. package/src/lib/model/index.js +16 -0
  286. package/src/lib/model/index.js.map +1 -1
  287. package/src/lib/model/order-events.d.ts +154 -0
  288. package/src/lib/model/order-events.js +153 -0
  289. package/src/lib/model/order-events.js.map +1 -0
  290. package/src/lib/model/order-fulfillment.d.ts +117 -0
  291. package/src/lib/model/order-fulfillment.js +217 -0
  292. package/src/lib/model/order-fulfillment.js.map +1 -0
  293. package/src/lib/model/order-history.d.ts +58 -0
  294. package/src/lib/model/order-history.js +22 -0
  295. package/src/lib/model/order-history.js.map +1 -0
  296. package/src/lib/model/order-list-fields.d.ts +9 -1
  297. package/src/lib/model/order-list-fields.js +7 -1
  298. package/src/lib/model/order-list-fields.js.map +1 -1
  299. package/src/lib/model/order-shipping-export.d.ts +91 -0
  300. package/src/lib/model/order-shipping-export.js +192 -0
  301. package/src/lib/model/order-shipping-export.js.map +1 -0
  302. package/src/lib/model/order-status-view.d.ts +103 -0
  303. package/src/lib/model/order-status-view.js +156 -0
  304. package/src/lib/model/order-status-view.js.map +1 -0
  305. package/src/lib/model/order-webhooks.d.ts +142 -0
  306. package/src/lib/model/order-webhooks.js +91 -0
  307. package/src/lib/model/order-webhooks.js.map +1 -0
  308. package/src/lib/model/product-channel.d.ts +56 -0
  309. package/src/lib/model/product-channel.js +86 -0
  310. package/src/lib/model/product-channel.js.map +1 -0
  311. package/src/lib/model/product-modifiers.d.ts +80 -0
  312. package/src/lib/model/product-modifiers.js +140 -0
  313. package/src/lib/model/product-modifiers.js.map +1 -0
  314. package/src/lib/model/product-write.d.ts +186 -0
  315. package/src/lib/model/product-write.js +116 -0
  316. package/src/lib/model/product-write.js.map +1 -0
  317. package/src/lib/model/shippingeasy.d.ts +94 -0
  318. package/src/lib/model/shippingeasy.js +267 -0
  319. package/src/lib/model/shippingeasy.js.map +1 -0
  320. package/src/lib/model/shipstation.d.ts +125 -0
  321. package/src/lib/model/shipstation.js +399 -0
  322. package/src/lib/model/shipstation.js.map +1 -0
  323. package/src/lib/model/smart-collection-reads.d.ts +32 -0
  324. package/src/lib/model/smart-collection-reads.js +63 -0
  325. package/src/lib/model/smart-collection-reads.js.map +1 -0
  326. package/src/lib/model/tracking-url.d.ts +74 -0
  327. package/src/lib/model/tracking-url.js +159 -0
  328. package/src/lib/model/tracking-url.js.map +1 -0
  329. package/src/lib/plugin-config.d.ts +13 -0
  330. package/src/lib/plugin-config.js +77 -5
  331. package/src/lib/plugin-config.js.map +1 -1
  332. package/src/lib/plugin.js +26 -0
  333. package/src/lib/plugin.js.map +1 -1
  334. package/src/lib/pos-ops-config.d.ts +39 -0
  335. package/src/lib/pos-ops-config.js +88 -0
  336. package/src/lib/pos-ops-config.js.map +1 -0
  337. package/src/lib/printing/print-document.d.ts +106 -0
  338. package/src/lib/printing/print-document.js +464 -0
  339. package/src/lib/printing/print-document.js.map +1 -0
  340. package/src/lib/printing/product-labels.d.ts +58 -0
  341. package/src/lib/printing/product-labels.js +116 -0
  342. package/src/lib/printing/product-labels.js.map +1 -0
  343. package/src/lib/printing/render-epson.d.ts +57 -0
  344. package/src/lib/printing/render-epson.js +135 -0
  345. package/src/lib/printing/render-epson.js.map +1 -0
  346. package/src/lib/printing/render-star.d.ts +45 -0
  347. package/src/lib/printing/render-star.js +100 -0
  348. package/src/lib/printing/render-star.js.map +1 -0
  349. package/src/lib/printing/render-text.d.ts +25 -0
  350. package/src/lib/printing/render-text.js +53 -0
  351. package/src/lib/printing/render-text.js.map +1 -0
  352. package/src/lib/server/api-v1/openapi.js +27 -4
  353. package/src/lib/server/api-v1/openapi.js.map +1 -1
  354. package/src/lib/server/api-v1/order-view.d.ts +67 -0
  355. package/src/lib/server/api-v1/order-view.js +120 -0
  356. package/src/lib/server/api-v1/order-view.js.map +1 -0
  357. package/src/lib/server/api-v1/orders-and-products.js +58 -65
  358. package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
  359. package/src/lib/server/billing-webhook.js +135 -28
  360. package/src/lib/server/billing-webhook.js.map +1 -1
  361. package/src/lib/server/cancel-order.js +29 -0
  362. package/src/lib/server/cancel-order.js.map +1 -1
  363. package/src/lib/server/carrier-rates-availability.d.ts +26 -0
  364. package/src/lib/server/carrier-rates-availability.js +76 -0
  365. package/src/lib/server/carrier-rates-availability.js.map +1 -0
  366. package/src/lib/server/carrier-shipping.d.ts +84 -0
  367. package/src/lib/server/carrier-shipping.js +135 -0
  368. package/src/lib/server/carrier-shipping.js.map +1 -0
  369. package/src/lib/server/cart-checkout.d.ts +2 -0
  370. package/src/lib/server/cart-checkout.js +226 -22
  371. package/src/lib/server/cart-checkout.js.map +1 -1
  372. package/src/lib/server/channel-order-updates.d.ts +50 -0
  373. package/src/lib/server/channel-order-updates.js +290 -0
  374. package/src/lib/server/channel-order-updates.js.map +1 -0
  375. package/src/lib/server/channel-orders.d.ts +85 -0
  376. package/src/lib/server/channel-orders.js +543 -0
  377. package/src/lib/server/channel-orders.js.map +1 -0
  378. package/src/lib/server/checkout-extras.d.ts +64 -0
  379. package/src/lib/server/checkout-extras.js +157 -0
  380. package/src/lib/server/checkout-extras.js.map +1 -0
  381. package/src/lib/server/{feed.d.ts → checkout-status.d.ts} +2 -7
  382. package/src/lib/server/checkout-status.js +111 -0
  383. package/src/lib/server/checkout-status.js.map +1 -0
  384. package/src/lib/server/checkout.js +86 -9
  385. package/src/lib/server/checkout.js.map +1 -1
  386. package/src/lib/server/draft-order.js +34 -5
  387. package/src/lib/server/draft-order.js.map +1 -1
  388. package/src/lib/server/fulfill-order.d.ts +127 -10
  389. package/src/lib/server/fulfill-order.js +451 -49
  390. package/src/lib/server/fulfill-order.js.map +1 -1
  391. package/src/lib/server/legacy-feed.d.ts +28 -0
  392. package/src/lib/server/legacy-feed.js +52 -0
  393. package/src/lib/server/legacy-feed.js.map +1 -0
  394. package/src/lib/server/native-checkout.d.ts +34 -15
  395. package/src/lib/server/native-checkout.js +32 -17
  396. package/src/lib/server/native-checkout.js.map +1 -1
  397. package/src/lib/server/order-event-host-emit.d.ts +23 -0
  398. package/src/lib/server/order-event-host-emit.js +30 -0
  399. package/src/lib/server/order-event-host-emit.js.map +1 -0
  400. package/src/lib/server/order-event-triggers.d.ts +37 -0
  401. package/src/lib/server/order-event-triggers.js +119 -0
  402. package/src/lib/server/order-event-triggers.js.map +1 -0
  403. package/src/lib/server/order-events.d.ts +62 -0
  404. package/src/lib/server/order-events.js +109 -0
  405. package/src/lib/server/order-events.js.map +1 -0
  406. package/src/lib/server/order-history.d.ts +23 -0
  407. package/src/lib/server/order-history.js +65 -0
  408. package/src/lib/server/order-history.js.map +1 -0
  409. package/src/lib/server/order-notifications.d.ts +185 -0
  410. package/src/lib/server/order-notifications.js +567 -0
  411. package/src/lib/server/order-notifications.js.map +1 -0
  412. package/src/lib/server/order-receipt-send.d.ts +39 -0
  413. package/src/lib/server/order-receipt-send.js +151 -0
  414. package/src/lib/server/order-receipt-send.js.map +1 -0
  415. package/src/lib/server/order-status-token.d.ts +31 -0
  416. package/src/lib/server/order-status-token.js +75 -0
  417. package/src/lib/server/order-status-token.js.map +1 -0
  418. package/src/lib/server/order-status.d.ts +58 -0
  419. package/src/lib/server/order-status.js +141 -0
  420. package/src/lib/server/order-status.js.map +1 -0
  421. package/src/lib/server/order-webhooks.d.ts +108 -0
  422. package/src/lib/server/order-webhooks.js +622 -0
  423. package/src/lib/server/order-webhooks.js.map +1 -0
  424. package/src/lib/server/orders-shipping-prepare.d.ts +26 -0
  425. package/src/lib/server/orders-shipping-prepare.js +121 -0
  426. package/src/lib/server/orders-shipping-prepare.js.map +1 -0
  427. package/src/lib/server/payment-method-domains.d.ts +209 -0
  428. package/src/lib/server/payment-method-domains.js +444 -0
  429. package/src/lib/server/payment-method-domains.js.map +1 -0
  430. package/src/lib/server/payment-methods.d.ts +77 -0
  431. package/src/lib/server/payment-methods.js +284 -0
  432. package/src/lib/server/payment-methods.js.map +1 -0
  433. package/src/lib/server/pos-auth.d.ts +50 -0
  434. package/src/lib/server/pos-auth.js +121 -0
  435. package/src/lib/server/pos-auth.js.map +1 -0
  436. package/src/lib/server/pos-customer.d.ts +49 -0
  437. package/src/lib/server/pos-customer.js +257 -0
  438. package/src/lib/server/pos-customer.js.map +1 -0
  439. package/src/lib/server/pos-display.d.ts +57 -0
  440. package/src/lib/server/pos-display.js +419 -0
  441. package/src/lib/server/pos-display.js.map +1 -0
  442. package/src/lib/server/pos-fee-month.d.ts +34 -0
  443. package/src/lib/server/pos-fee-month.js +36 -0
  444. package/src/lib/server/pos-fee-month.js.map +1 -0
  445. package/src/lib/server/pos-ops-gate.d.ts +161 -0
  446. package/src/lib/server/pos-ops-gate.js +295 -0
  447. package/src/lib/server/pos-ops-gate.js.map +1 -0
  448. package/src/lib/server/pos-ops-routes.d.ts +22 -0
  449. package/src/lib/server/pos-ops-routes.js +36 -0
  450. package/src/lib/server/pos-ops-routes.js.map +1 -0
  451. package/src/lib/server/pos-order.d.ts +1 -18
  452. package/src/lib/server/pos-order.js +222 -42
  453. package/src/lib/server/pos-order.js.map +1 -1
  454. package/src/lib/server/pos-payment.d.ts +39 -0
  455. package/src/lib/server/pos-payment.js +922 -0
  456. package/src/lib/server/pos-payment.js.map +1 -0
  457. package/src/lib/server/pos-print.d.ts +82 -0
  458. package/src/lib/server/pos-print.js +193 -0
  459. package/src/lib/server/pos-print.js.map +1 -0
  460. package/src/lib/server/pos-readers.d.ts +27 -0
  461. package/src/lib/server/pos-readers.js +276 -0
  462. package/src/lib/server/pos-readers.js.map +1 -0
  463. package/src/lib/server/pos-refund-authority.d.ts +60 -0
  464. package/src/lib/server/pos-refund-authority.js +72 -0
  465. package/src/lib/server/pos-refund-authority.js.map +1 -0
  466. package/src/lib/server/pos-return.d.ts +58 -0
  467. package/src/lib/server/pos-return.js +891 -0
  468. package/src/lib/server/pos-return.js.map +1 -0
  469. package/src/lib/server/pos-sale-stamp.d.ts +66 -0
  470. package/src/lib/server/pos-sale-stamp.js +84 -0
  471. package/src/lib/server/pos-sale-stamp.js.map +1 -0
  472. package/src/lib/server/pos-sale.d.ts +170 -0
  473. package/src/lib/server/pos-sale.js +461 -0
  474. package/src/lib/server/pos-sale.js.map +1 -0
  475. package/src/lib/server/pos-shift.d.ts +45 -0
  476. package/src/lib/server/pos-shift.js +484 -0
  477. package/src/lib/server/pos-shift.js.map +1 -0
  478. package/src/lib/server/pos-staff-pin.d.ts +26 -0
  479. package/src/lib/server/pos-staff-pin.js +339 -0
  480. package/src/lib/server/pos-staff-pin.js.map +1 -0
  481. package/src/lib/server/pos-stripe.d.ts +91 -0
  482. package/src/lib/server/pos-stripe.js +129 -0
  483. package/src/lib/server/pos-stripe.js.map +1 -0
  484. package/src/lib/server/pos-terminal-connection-token.d.ts +48 -0
  485. package/src/lib/server/pos-terminal-connection-token.js +166 -0
  486. package/src/lib/server/pos-terminal-connection-token.js.map +1 -0
  487. package/src/lib/server/pos-terminal.d.ts +218 -0
  488. package/src/lib/server/pos-terminal.js +1014 -0
  489. package/src/lib/server/pos-terminal.js.map +1 -0
  490. package/src/lib/server/print-queue.d.ts +124 -0
  491. package/src/lib/server/print-queue.js +301 -0
  492. package/src/lib/server/print-queue.js.map +1 -0
  493. package/src/lib/server/printer-poll.d.ts +75 -0
  494. package/src/lib/server/printer-poll.js +325 -0
  495. package/src/lib/server/printer-poll.js.map +1 -0
  496. package/src/lib/server/printer-secret.d.ts +39 -0
  497. package/src/lib/server/printer-secret.js +56 -0
  498. package/src/lib/server/printer-secret.js.map +1 -0
  499. package/src/lib/server/printers.d.ts +114 -0
  500. package/src/lib/server/printers.js +546 -0
  501. package/src/lib/server/printers.js.map +1 -0
  502. package/src/lib/server/product-catalog.d.ts +42 -0
  503. package/src/lib/server/product-catalog.js +309 -0
  504. package/src/lib/server/product-catalog.js.map +1 -0
  505. package/src/lib/server/product-drafts.d.ts +5 -1
  506. package/src/lib/server/product-drafts.js +3 -3
  507. package/src/lib/server/product-drafts.js.map +1 -1
  508. package/src/lib/server/product-writer.d.ts +19 -0
  509. package/src/lib/server/product-writer.js +261 -0
  510. package/src/lib/server/product-writer.js.map +1 -0
  511. package/src/lib/server/products-write.d.ts +61 -0
  512. package/src/lib/server/products-write.js +375 -0
  513. package/src/lib/server/products-write.js.map +1 -0
  514. package/src/lib/server/refund.js +110 -45
  515. package/src/lib/server/refund.js.map +1 -1
  516. package/src/lib/server/reserve.js +2 -0
  517. package/src/lib/server/reserve.js.map +1 -1
  518. package/src/lib/server/return-status-action.d.ts +37 -0
  519. package/src/lib/server/return-status-action.js +57 -0
  520. package/src/lib/server/return-status-action.js.map +1 -0
  521. package/src/lib/server/returns.d.ts +119 -0
  522. package/src/lib/server/returns.js +938 -0
  523. package/src/lib/server/returns.js.map +1 -0
  524. package/src/lib/server/shipment-records.d.ts +36 -0
  525. package/src/lib/server/shipment-records.js +289 -0
  526. package/src/lib/server/shipment-records.js.map +1 -0
  527. package/src/lib/server/shipping-connector-gates.d.ts +40 -0
  528. package/src/lib/server/shipping-connector-gates.js +97 -0
  529. package/src/lib/server/shipping-connector-gates.js.map +1 -0
  530. package/src/lib/server/shipping-connectors.d.ts +29 -0
  531. package/src/lib/server/shipping-connectors.js +236 -0
  532. package/src/lib/server/shipping-connectors.js.map +1 -0
  533. package/src/lib/server/shippingeasy.d.ts +238 -0
  534. package/src/lib/server/shippingeasy.js +787 -0
  535. package/src/lib/server/shippingeasy.js.map +1 -0
  536. package/src/lib/server/shipstation.d.ts +129 -0
  537. package/src/lib/server/shipstation.js +483 -0
  538. package/src/lib/server/shipstation.js.map +1 -0
  539. package/src/lib/server/site-page-resolver.d.ts +5 -0
  540. package/src/lib/server/site-page-resolver.js +156 -1
  541. package/src/lib/server/site-page-resolver.js.map +1 -1
  542. package/src/lib/server/stock-levels.d.ts +21 -0
  543. package/src/lib/server/stock-levels.js +263 -0
  544. package/src/lib/server/stock-levels.js.map +1 -0
  545. package/src/lib/server/stripe-refund.d.ts +47 -0
  546. package/src/lib/server/stripe-refund.js +87 -0
  547. package/src/lib/server/stripe-refund.js.map +1 -0
  548. package/src/lib/server/supplier-update.js +46 -5
  549. package/src/lib/server/supplier-update.js.map +1 -1
  550. package/src/lib/server/tax-engine-quote.d.ts +47 -0
  551. package/src/lib/server/tax-engine-quote.js +105 -0
  552. package/src/lib/server/tax-engine-quote.js.map +1 -0
  553. package/src/lib/server.js +143 -2
  554. package/src/lib/server.js.map +1 -1
  555. package/src/lib/site.js +12 -0
  556. package/src/lib/site.js.map +1 -1
  557. package/src/lib/subprocessors.d.ts +26 -0
  558. package/src/lib/subprocessors.js +50 -0
  559. package/src/lib/subprocessors.js.map +1 -0
  560. package/src/lib/tenant-emails.js +461 -3
  561. package/src/lib/tenant-emails.js.map +1 -1
  562. package/src/lib/testing/fake-firestore.d.ts +45 -0
  563. package/src/lib/testing/fake-firestore.js +189 -0
  564. package/src/lib/testing/fake-firestore.js.map +1 -0
  565. package/src/lib/testing/memory-firestore.d.ts +136 -0
  566. package/src/lib/testing/memory-firestore.js +282 -0
  567. package/src/lib/testing/memory-firestore.js.map +1 -0
  568. package/src/lib/testing/pos-ops-harness.d.ts +50 -0
  569. package/src/lib/testing/pos-ops-harness.js +184 -0
  570. package/src/lib/testing/pos-ops-harness.js.map +1 -0
  571. package/src/lib/testing/pos-ops-memory-firestore.d.ts +55 -0
  572. package/src/lib/testing/pos-ops-memory-firestore.js +376 -0
  573. package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -0
  574. package/src/lib/transfer/products.server.d.ts +5 -0
  575. package/src/lib/transfer/products.server.js +2 -2
  576. package/src/lib/transfer/products.server.js.map +1 -1
  577. package/src/lib/transfer/records-transfer.d.ts +11 -1
  578. package/src/lib/transfer/records-transfer.js +127 -5
  579. package/src/lib/transfer/records-transfer.js.map +1 -1
  580. package/src/lib/transfer/records.server.d.ts +9 -2
  581. package/src/lib/transfer/records.server.js +58 -7
  582. package/src/lib/transfer/records.server.js.map +1 -1
  583. package/src/lib/transfer/register-transfer-resources.js +40 -1
  584. package/src/lib/transfer/register-transfer-resources.js.map +1 -1
  585. package/src/lib/transfer/register-transfer-ui.js +4 -1
  586. package/src/lib/transfer/register-transfer-ui.js.map +1 -1
  587. package/src/lib/transfer/shipping-presets.d.ts +23 -0
  588. package/src/lib/transfer/shipping-presets.js +156 -0
  589. package/src/lib/transfer/shipping-presets.js.map +1 -0
  590. package/src/lib/transfer/tracking-transfer.d.ts +101 -0
  591. package/src/lib/transfer/tracking-transfer.js +546 -0
  592. package/src/lib/transfer/tracking-transfer.js.map +1 -0
  593. package/src/lib/transfer/tracking.server.d.ts +37 -0
  594. package/src/lib/transfer/tracking.server.js +393 -0
  595. package/src/lib/transfer/tracking.server.js.map +1 -0
  596. package/src/lib/transfer/transfer-keys.d.ts +2 -1
  597. package/src/lib/transfer/transfer-keys.js +6 -2
  598. package/src/lib/transfer/transfer-keys.js.map +1 -1
  599. package/src/lib/utils/code128.d.ts +37 -0
  600. package/src/lib/utils/code128.js +199 -0
  601. package/src/lib/utils/code128.js.map +1 -0
  602. package/src/lib/utils/order-invoice.d.ts +55 -0
  603. package/src/lib/utils/order-invoice.js +127 -0
  604. package/src/lib/utils/order-invoice.js.map +1 -0
  605. package/src/lib/utils/use-checkout-return-notice.d.ts +34 -0
  606. package/src/lib/utils/use-checkout-return-notice.js +78 -0
  607. package/src/lib/utils/use-checkout-return-notice.js.map +1 -0
  608. package/src/lib/server/feed.js +0 -69
  609. package/src/lib/server/feed.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/printing/render-star.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 { toPrintable, type PrintDocument } from './print-document'\n\n/**\n * Star command bytes for a {@link PrintDocument} (AGL-3619), served to a\n * CloudPRNT printer as `application/vnd.star.starprntcore`: the subset of\n * StarPRNT that both Star Line Mode and StarPRNT emulation execute, so one\n * job prints on an mC-Print3, a TSP143IV and a legacy TSP650II alike.\n *\n * Every command used here is in that common subset:\n *\n * | bytes | command |\n * | --------------------- | ----------------------------------------- |\n * | `1B 40` | initialize |\n * | `1B 1D 61 n` | alignment (0 left, 1 center, 2 right) |\n * | `1B 45` / `1B 46` | emphasis on / off |\n * | `1B 69 h w` | character expansion (0 = normal, 1 = 2x) |\n * | `1B 62 06 02 02 h d… 1E` | Code128, text below, 3-dot module, `h` dots tall |\n * | `1B 1C 70 n 00` | print NV logo `n` |\n * | `07` | drive external device 1 (the cash drawer) |\n * | `1B 64 03` | feed to the cutter and partial cut |\n * | `0A` | line feed |\n */\nexport const STAR_MEDIA_TYPE = 'application/vnd.star.starprntcore'\n\nconst ESC = 0x1b\nconst GS = 0x1d\nconst LF = 0x0a\n\n/** The drawer kick on its own, the bytes a \"paid out\" job sends: BEL drives drawer 1. */\nexport const STAR_DRAWER_KICK = [0x07] as const\n\nconst BARCODE_HEIGHT_DOTS = 80\n\nfunction ascii(text: string): number[] {\n return Array.from(toPrintable(text), (char) => char.charCodeAt(0))\n}\n\n/** Star's NV logo number, 1-255; anything else prints no logo. */\nexport function starLogoNumber(logoKey: string | undefined): number | null {\n const value = Number(String(logoKey ?? '').trim())\n return Number.isInteger(value) && value >= 1 && value <= 255 ? value : null\n}\n\nexport function renderStar(document: PrintDocument, options: { logoKey?: string } = {}): Uint8Array {\n const bytes: number[] = [ESC, 0x40]\n const logo = starLogoNumber(options.logoKey)\n let align = 0\n const setAlign = (next: number) => {\n if (next === align) return\n bytes.push(ESC, GS, 0x61, next)\n align = next\n }\n for (const op of document.ops) {\n switch (op.op) {\n case 'text': {\n setAlign(op.align === 'center' ? 1 : op.align === 'right' ? 2 : 0)\n const expand = op.size === 2 ? 1 : 0\n if (expand) bytes.push(ESC, 0x69, expand, expand)\n if (op.bold) bytes.push(ESC, 0x45)\n bytes.push(...ascii(op.text), LF)\n if (op.bold) bytes.push(ESC, 0x46)\n if (expand) bytes.push(ESC, 0x69, 0, 0)\n break\n }\n case 'feed':\n for (let index = 0; index < Math.max(0, Math.min(10, op.lines)); index += 1) bytes.push(LF)\n break\n case 'barcode':\n setAlign(1)\n bytes.push(ESC, 0x62, 0x06, 0x02, 0x02, BARCODE_HEIGHT_DOTS, ...ascii(op.data), 0x1e, LF)\n break\n case 'logo':\n if (logo !== null) {\n setAlign(1)\n bytes.push(ESC, 0x1c, 0x70, logo, 0x00)\n }\n break\n case 'drawer':\n bytes.push(...STAR_DRAWER_KICK)\n break\n case 'cut':\n bytes.push(ESC, 0x64, 0x03)\n break\n }\n }\n return Uint8Array.from(bytes)\n}\n"],"names":["toPrintable","STAR_MEDIA_TYPE","ESC","GS","LF","STAR_DRAWER_KICK","BARCODE_HEIGHT_DOTS","ascii","text","Array","from","char","charCodeAt","starLogoNumber","logoKey","value","Number","String","trim","isInteger","renderStar","document","options","bytes","logo","align","setAlign","next","push","op","ops","expand","size","bold","index","Math","max","min","lines","data","Uint8Array"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAA4B,sBAAkB;AAElE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,kBAAkB,oCAAmC;AAElE,MAAMC,MAAM;AACZ,MAAMC,KAAK;AACX,MAAMC,KAAK;AAEX,uFAAuF,GACvF,OAAO,MAAMC,mBAAmB;IAAC;CAAK,CAAS;AAE/C,MAAMC,sBAAsB;AAE5B,SAASC,MAAMC,IAAY;IACzB,OAAOC,MAAMC,IAAI,CAACV,YAAYQ,OAAO,CAACG,OAASA,KAAKC,UAAU,CAAC;AACjE;AAEA,gEAAgE,GAChE,OAAO,SAASC,eAAeC,OAA2B;IACxD,MAAMC,QAAQC,OAAOC,OAAOH,kBAAAA,UAAW,IAAII,IAAI;IAC/C,OAAOF,OAAOG,SAAS,CAACJ,UAAUA,SAAS,KAAKA,SAAS,MAAMA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AC1B,KAAK,MAAM,MAAMsB,MAAM;gBACpC;gBACA;YACF,KAAK;gBACHD,MAAMK,IAAI,IAAIvB;gBACd;YACF,KAAK;gBACHkB,MAAMK,IAAI,CAAC1B,KAAK,MAAM;gBACtB;QACJ;IACF;IACA,OAAOsC,WAAW9B,IAAI,CAACa;AACzB"}
@@ -0,0 +1,25 @@
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 PrintDocument } from './print-document';
18
+ /**
19
+ * A {@link PrintDocument} as plain text (AGL-3619): the `text/plain` fallback
20
+ * a CloudPRNT printer may choose, and what a spec snapshots to read a layout
21
+ * at a glance. Size and emphasis do not exist in plain text; alignment is
22
+ * padding; a barcode prints its data between brackets; a drawer kick and a
23
+ * cut print nothing.
24
+ */
25
+ export declare function renderText(layout: PrintDocument): string;
@@ -0,0 +1,53 @@
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 { toPrintable } from "./print-document.js";
17
+ /**
18
+ * A {@link PrintDocument} as plain text (AGL-3619): the `text/plain` fallback
19
+ * a CloudPRNT printer may choose, and what a spec snapshots to read a layout
20
+ * at a glance. Size and emphasis do not exist in plain text; alignment is
21
+ * padding; a barcode prints its data between brackets; a drawer kick and a
22
+ * cut print nothing.
23
+ */ export function renderText(layout) {
24
+ const { columns } = layout;
25
+ const lines = [];
26
+ for (const op of layout.ops){
27
+ switch(op.op){
28
+ case 'text':
29
+ {
30
+ const text = toPrintable(op.text).slice(0, columns);
31
+ const gap = columns - text.length;
32
+ if (op.align === 'center') lines.push(`${' '.repeat(Math.floor(gap / 2))}${text}`.trimEnd());
33
+ else if (op.align === 'right') lines.push(`${' '.repeat(gap)}${text}`);
34
+ else lines.push(text);
35
+ break;
36
+ }
37
+ case 'feed':
38
+ for(let index = 0; index < op.lines; index += 1)lines.push('');
39
+ break;
40
+ case 'barcode':
41
+ {
42
+ const text = `[${toPrintable(op.data)}]`;
43
+ lines.push(`${' '.repeat(Math.max(0, Math.floor((columns - text.length) / 2)))}${text}`);
44
+ break;
45
+ }
46
+ default:
47
+ break;
48
+ }
49
+ }
50
+ return `${lines.join('\n')}\n`;
51
+ }
52
+
53
+ //# sourceMappingURL=render-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/printing/render-text.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 { toPrintable, type PrintDocument } from './print-document'\n\n/**\n * A {@link PrintDocument} as plain text (AGL-3619): the `text/plain` fallback\n * a CloudPRNT printer may choose, and what a spec snapshots to read a layout\n * at a glance. Size and emphasis do not exist in plain text; alignment is\n * padding; a barcode prints its data between brackets; a drawer kick and a\n * cut print nothing.\n */\nexport function renderText(layout: PrintDocument): string {\n const { columns } = layout\n const lines: string[] = []\n for (const op of layout.ops) {\n switch (op.op) {\n case 'text': {\n const text = toPrintable(op.text).slice(0, columns)\n const gap = columns - text.length\n if (op.align === 'center') lines.push(`${' '.repeat(Math.floor(gap / 2))}${text}`.trimEnd())\n else if (op.align === 'right') lines.push(`${' '.repeat(gap)}${text}`)\n else lines.push(text)\n break\n }\n case 'feed':\n for (let index = 0; index < op.lines; index += 1) lines.push('')\n break\n case 'barcode': {\n const text = `[${toPrintable(op.data)}]`\n lines.push(`${' '.repeat(Math.max(0, Math.floor((columns - text.length) / 2)))}${text}`)\n break\n }\n default:\n break\n }\n }\n return `${lines.join('\\n')}\\n`\n}\n"],"names":["toPrintable","renderText","layout","columns","lines","op","ops","text","slice","gap","length","align","push","repeat","Math","floor","trimEnd","index","data","max","join"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAA4B,sBAAkB;AAElE;;;;;;CAMC,GACD,OAAO,SAASC,WAAWC,MAAqB;IAC9C,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,MAAME,QAAkB,EAAE;IAC1B,KAAK,MAAMC,MAAMH,OAAOI,GAAG,CAAE;QAC3B,OAAQD,GAAGA,EAAE;YACX,KAAK;gBAAQ;oBACX,MAAME,OAAOP,YAAYK,GAAGE,IAAI,EAAEC,KAAK,CAAC,GAAGL;oBAC3C,MAAMM,MAAMN,UAAUI,KAAKG,MAAM;oBACjC,IAAIL,GAAGM,KAAK,KAAK,UAAUP,MAAMQ,IAAI,CAAC,GAAG,IAAIC,MAAM,CAACC,KAAKC,KAAK,CAACN,MAAM,MAAMF,MAAM,CAACS,OAAO;yBACpF,IAAIX,GAAGM,KAAK,KAAK,SAASP,MAAMQ,IAAI,CAAC,GAAG,IAAIC,MAAM,CAACJ,OAAOF,MAAM;yBAChEH,MAAMQ,IAAI,CAACL;oBAChB;gBACF;YACA,KAAK;gBACH,IAAK,IAAIU,QAAQ,GAAGA,QAAQZ,GAAGD,KAAK,EAAEa,SAAS,EAAGb,MAAMQ,IAAI,CAAC;gBAC7D;YACF,KAAK;gBAAW;oBACd,MAAML,OAAO,CAAC,CAAC,EAAEP,YAAYK,GAAGa,IAAI,EAAE,CAAC,CAAC;oBACxCd,MAAMQ,IAAI,CAAC,GAAG,IAAIC,MAAM,CAACC,KAAKK,GAAG,CAAC,GAAGL,KAAKC,KAAK,CAAC,AAACZ,CAAAA,UAAUI,KAAKG,MAAM,AAAD,IAAK,OAAOH,MAAM;oBACvF;gBACF;YACA;gBACE;QACJ;IACF;IACA,OAAO,GAAGH,MAAMgB,IAAI,CAAC,MAAM,EAAE,CAAC;AAChC"}
@@ -109,7 +109,10 @@ export const ORDERS_API_V1_DESCRIPTION = {
109
109
  writable: [
110
110
  'status',
111
111
  'carrier',
112
- 'trackingNumber'
112
+ 'trackingNumber',
113
+ 'trackingUrl',
114
+ 'lineItems',
115
+ 'notify'
113
116
  ],
114
117
  writeOnly: {
115
118
  status: {
@@ -120,8 +123,18 @@ export const ORDERS_API_V1_DESCRIPTION = {
120
123
  ],
121
124
  description: 'The status to move the order to.'
122
125
  },
123
- carrier: str('Free text, e.g. `UPS`. Trimmed to 40 characters.'),
124
- trackingNumber: str('Free text. Trimmed to 60 characters.')
126
+ carrier: str('Free text, e.g. `UPS`. Trimmed to 40 characters. USPS, UPS, FedEx, DHL, Canada Post, Royal Mail and Australia Post get a tracking link.'),
127
+ trackingNumber: str('Free text. Trimmed to 60 characters.'),
128
+ trackingUrl: str('An https tracking link, for a carrier the link is not derived for.'),
129
+ lineItems: {
130
+ type: 'array',
131
+ description: 'With `status: fulfilled`, the units this shipment covers: `[{ lineItemId, quantity }]`, where `lineItemId` is the line’s index. Omitted, the shipment covers everything still to ship. More than is left is `409 conflict` (`code: "over_fulfilled"`). Send an `Idempotency-Key` header so a retried partial shipment is recorded once.',
132
+ items: {
133
+ type: 'object',
134
+ additionalProperties: true
135
+ }
136
+ },
137
+ notify: bool('Whether the buyer is told about this shipment. Defaults to true.')
125
138
  },
126
139
  writeRequired: [
127
140
  'status'
@@ -143,9 +156,19 @@ export const ORDERS_API_V1_DESCRIPTION = {
143
156
  additionalProperties: true
144
157
  }
145
158
  },
146
- totals: objectOf('Money totals, in the smallest unit of `currency`.'),
159
+ totals: objectOf('Money totals, in the smallest unit of `currency`. `extrasCents` is the optional lines the buyer added at checkout, inside `totalCents` and outside `itemsCents`.'),
160
+ extras: {
161
+ type: 'array',
162
+ description: 'Optional lines the buyer added at checkout, such as package protection: `[{ id, pluginId, key, label, amountCents, quoteRef }]`. Empty when there were none.',
163
+ items: {
164
+ type: 'object',
165
+ additionalProperties: true
166
+ }
167
+ },
147
168
  refundedCents: int('Amount refunded so far.'),
148
169
  disputed: bool('Whether a chargeback is open.'),
170
+ taxMode: nullable(str('The tax regime: `stripe-automatic` (Stripe Tax, collected and remitted by the platform as marketplace facilitator), `manual` (your own rate) or `none`. `null` on an order from before it was recorded.')),
171
+ taxEngine: nullable(objectOf('The tax service you connected, when one was asked for this sale’s tax: `provider` (`avalara` or `taxjar`), `providerLabel`, `status` (`quoted` when its tax was charged, `fallback` when it did not answer and your own rate was charged), `reason` (`timeout` or `error` on a fallback) and `sandbox`. `null` when no service was asked.')),
149
172
  shippingAddress: ADDRESS(),
150
173
  couponCode: nullable(str('Coupon applied.')),
151
174
  fulfillments: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/server/api-v1/openapi.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 {\n type ApiV1ResourceDescription,\n booleanField as bool,\n integerField as int,\n nullableField as nullable,\n objectKindField as OBJECT_FIELD,\n openObjectField as objectOf,\n postalAddressField as ADDRESS,\n queryParam as q,\n RECORD_STAMPS as STAMPS,\n stringField as str,\n stringListField as strList,\n} from '@aglyn/tenant-data-admin/server/api-v1-description'\n\n/**\n * A site's products and orders as the customer API's OpenAPI document\n * describes them — what the console's builder turns into paths, tags and\n * schemas, and the MCP tools derive from. Transcribed unchanged from the\n * builder's own list when the resources moved here (AGL-3080);\n * `api-v1-openapi.spec.ts` holds the document to every endpoint the\n * documentation promises.\n */\nexport const PRODUCTS_API_V1_DESCRIPTION: ApiV1ResourceDescription = {\n tag: 'Products',\n description: 'A site’s catalog. Read-only over the API.',\n schemaName: 'Product',\n required: ['id', 'object', 'name'],\n fields: {\n id: str('Product id.'),\n object: OBJECT_FIELD('product'),\n name: str('Product name.'),\n slug: str('URL slug.'),\n description: nullable(str('Description.')),\n type: str('Product type.'),\n status: str('Publication status.'),\n tags: strList('Free-form tags.'),\n categoryIds: strList('Categories this product belongs to.'),\n mediaUrls: strList('Image URLs.'),\n options: { type: 'array', description: 'Option definitions, e.g. size.', items: { type: 'object', additionalProperties: true } },\n variants: { type: 'array', description: 'Purchasable variants.', items: { type: 'object', additionalProperties: true } },\n inventory: nullable(int('Stock on hand, when tracked.')),\n subscription: nullable(objectOf('Subscription terms, when the product is one.')),\n ...STAMPS,\n },\n ops: [\n { path: '/v1/sites/{siteId}/products', method: 'get', operationId: 'listProducts', summary: 'List products', list: true, returns: 'Product', description: 'Rows deleted since they were written are dropped after the read, so pages can come back short.', pathParams: [{ name: 'siteId', description: 'Site id.' }] },\n { path: '/v1/sites/{siteId}/products/{productId}', method: 'get', operationId: 'getProduct', summary: 'Retrieve a product', returns: 'Product', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'productId', description: 'Product id.' }] },\n ],\n}\n\nexport const ORDERS_API_V1_DESCRIPTION: ApiV1ResourceDescription = {\n tag: 'Orders',\n description: 'A site’s orders. Status moves are constrained.',\n schemaName: 'Order',\n required: ['id', 'object', 'number', 'status'],\n writable: ['status', 'carrier', 'trackingNumber'],\n writeOnly: {\n status: { type: 'string', enum: ['fulfilled', 'delivered'], description: 'The status to move the order to.' },\n carrier: str('Free text, e.g. `UPS`. Trimmed to 40 characters.'),\n trackingNumber: str('Free text. Trimmed to 60 characters.'),\n },\n writeRequired: ['status'],\n fields: {\n id: str('Order id.'),\n object: OBJECT_FIELD('order'),\n number: int('Human-facing order number.'),\n status: str('Order status.'),\n channel: str('`online` by default. Older orders carry no stored value, so `?channel=online` drops them after the read.'),\n currency: str('ISO 4217 code.'),\n customerEmail: nullable(str('Customer email.')),\n customerName: nullable(str('Customer name.')),\n lineItems: { type: 'array', description: 'What was bought.', items: { type: 'object', additionalProperties: true } },\n totals: objectOf('Money totals, in the smallest unit of `currency`.'),\n refundedCents: int('Amount refunded so far.'),\n disputed: bool('Whether a chargeback is open.'),\n shippingAddress: ADDRESS(),\n couponCode: nullable(str('Coupon applied.')),\n fulfillments: { type: 'array', description: 'Shipments and deliveries.', items: { type: 'object', additionalProperties: true } },\n created: STAMPS.created,\n },\n ops: [\n { path: '/v1/sites/{siteId}/orders', method: 'get', operationId: 'listOrders', summary: 'List orders', list: true, returns: 'Order', filters: [q('channel', '`online` is a default rather than a stored value, so filtering on it drops older orders after the read.'), q('status', 'Order status.')], pathParams: [{ name: 'siteId', description: 'Site id.' }] },\n { path: '/v1/sites/{siteId}/orders/{orderId}', method: 'get', operationId: 'getOrder', summary: 'Retrieve an order', returns: 'Order', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'orderId', description: 'Order id.' }] },\n { path: '/v1/sites/{siteId}/orders/{orderId}', method: 'patch', operationId: 'updateOrder', summary: 'Move an order’s status', accepts: 'OrderWrite', returns: 'Order', description: 'An illegal transition is `409 conflict` (`code: \"order_transition\"`), and the message names the status it is in.', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'orderId', description: 'Order id.' }] },\n ],\n}\n"],"names":["booleanField","bool","integerField","int","nullableField","nullable","objectKindField","OBJECT_FIELD","openObjectField","objectOf","postalAddressField","ADDRESS","queryParam","q","RECORD_STAMPS","STAMPS","stringField","str","stringListField","strList","PRODUCTS_API_V1_DESCRIPTION","tag","description","schemaName","required","fields","id","object","name","slug","type","status","tags","categoryIds","mediaUrls","options","items","additionalProperties","variants","inventory","subscription","ops","path","method","operationId","summary","list","returns","pathParams","ORDERS_API_V1_DESCRIPTION","writable","writeOnly","enum","carrier","trackingNumber","writeRequired","number","channel","currency","customerEmail","customerName","lineItems","totals","refundedCents","disputed","shippingAddress","couponCode","fulfillments","created","filters","accepts"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAEEA,gBAAgBC,IAAI,EACpBC,gBAAgBC,GAAG,EACnBC,iBAAiBC,QAAQ,EACzBC,mBAAmBC,YAAY,EAC/BC,mBAAmBC,QAAQ,EAC3BC,sBAAsBC,OAAO,EAC7BC,cAAcC,CAAC,EACfC,iBAAiBC,MAAM,EACvBC,eAAeC,GAAG,EAClBC,mBAAmBC,OAAO,QACrB,qDAAoD;AAE3D;;;;;;;CAOC,GACD,OAAO,MAAMC,8BAAwD;IACnEC,KAAK;IACLC,aAAa;IACbC,YAAY;IACZC,UAAU;QAAC;QAAM;QAAU;KAAO;IAClCC,QAAQ;QACNC,IAAIT,IAAI;QACRU,QAAQpB,aAAa;QACrBqB,MAAMX,IAAI;QACVY,MAAMZ,IAAI;QACVK,aAAajB,SAASY,IAAI;QAC1Ba,MAAMb,IAAI;QACVc,QAAQd,IAAI;QACZe,MAAMb,QAAQ;QACdc,aAAad,QAAQ;QACrBe,WAAWf,QAAQ;QACnBgB,SAAS;YAAEL,MAAM;YAASR,aAAa;YAAkCc,OAAO;gBAAEN,MAAM;gBAAUO,sBAAsB;Y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IAAI;QACnB6D,UAAU/D,KAAK;QACfgE,iBAAiBtD;QACjBuD,YAAY7D,SAASY,IAAI;QACzBkD,cAAc;YAAErC,MAAM;YAASR,aAAa;YAA6Bc,OAAO;gBAAEN,MAAM;gBAAUO,sBAAsB;YAAK;QAAE;QAC/H+B,SAASrD,OAAOqD,OAAO;IACzB;IACA3B,KAAK;QACH;YAAEC,MAAM;YAA6BC,QAAQ;YAAOC,aAAa;YAAcC,SAAS;YAAeC,MAAM;YAAMC,SAAS;YAASsB,SAAS;gBAACxD,EAAE,WAAW;gBAA4GA,EAAE,UAAU;aAAiB;YAAEmC,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;aAAE;QAAC;QACjW;YAAEoB,MAAM;YAAuCC,QAAQ;YAAOC,aAAa;YAAYC,SAAS;YAAqBE,SAAS;YAASC,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;gBAAG;oBAAEM,MAAM;oBAAWN,aAAa;gBAAY;aAAE;QAAC;QAChP;YAAEoB,MAAM;YAAuCC,QAAQ;YAASC,aAAa;YAAeC,SAAS;YAA0ByB,SAAS;YAAcvB,SAAS;YAASzB,aAAa;YAAoH0B,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;gBAAG;oBAAEM,MAAM;oBAAWN,aAAa;gBAAY;aAAE;QAAC;KACnZ;AACH,EAAC"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/server/api-v1/openapi.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 {\n type ApiV1ResourceDescription,\n booleanField as bool,\n integerField as int,\n nullableField as nullable,\n objectKindField as OBJECT_FIELD,\n openObjectField as objectOf,\n postalAddressField as ADDRESS,\n queryParam as q,\n RECORD_STAMPS as STAMPS,\n stringField as str,\n stringListField as strList,\n} from '@aglyn/tenant-data-admin/server/api-v1-description'\n\n/**\n * A site's products and orders as the customer API's OpenAPI document\n * describes them — what the console's builder turns into paths, tags and\n * schemas, and the MCP tools derive from. Transcribed unchanged from the\n * builder's own list when the resources moved here (AGL-3080);\n * `api-v1-openapi.spec.ts` holds the document to every endpoint the\n * documentation promises.\n */\nexport const PRODUCTS_API_V1_DESCRIPTION: ApiV1ResourceDescription = {\n tag: 'Products',\n description: 'A site’s catalog. Read-only over the API.',\n schemaName: 'Product',\n required: ['id', 'object', 'name'],\n fields: {\n id: str('Product id.'),\n object: OBJECT_FIELD('product'),\n name: str('Product name.'),\n slug: str('URL slug.'),\n description: nullable(str('Description.')),\n type: str('Product type.'),\n status: str('Publication status.'),\n tags: strList('Free-form tags.'),\n categoryIds: strList('Categories this product belongs to.'),\n mediaUrls: strList('Image URLs.'),\n options: { type: 'array', description: 'Option definitions, e.g. size.', items: { type: 'object', additionalProperties: true } },\n variants: { type: 'array', description: 'Purchasable variants.', items: { type: 'object', additionalProperties: true } },\n inventory: nullable(int('Stock on hand, when tracked.')),\n subscription: nullable(objectOf('Subscription terms, when the product is one.')),\n ...STAMPS,\n },\n ops: [\n { path: '/v1/sites/{siteId}/products', method: 'get', operationId: 'listProducts', summary: 'List products', list: true, returns: 'Product', description: 'Rows deleted since they were written are dropped after the read, so pages can come back short.', pathParams: [{ name: 'siteId', description: 'Site id.' }] },\n { path: '/v1/sites/{siteId}/products/{productId}', method: 'get', operationId: 'getProduct', summary: 'Retrieve a product', returns: 'Product', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'productId', description: 'Product id.' }] },\n ],\n}\n\nexport const ORDERS_API_V1_DESCRIPTION: ApiV1ResourceDescription = {\n tag: 'Orders',\n description: 'A site’s orders. Status moves are constrained.',\n schemaName: 'Order',\n required: ['id', 'object', 'number', 'status'],\n writable: ['status', 'carrier', 'trackingNumber', 'trackingUrl', 'lineItems', 'notify'],\n writeOnly: {\n status: { type: 'string', enum: ['fulfilled', 'delivered'], description: 'The status to move the order to.' },\n carrier: str('Free text, e.g. `UPS`. Trimmed to 40 characters. USPS, UPS, FedEx, DHL, Canada Post, Royal Mail and Australia Post get a tracking link.'),\n trackingNumber: str('Free text. Trimmed to 60 characters.'),\n trackingUrl: str('An https tracking link, for a carrier the link is not derived for.'),\n lineItems: {\n type: 'array',\n description:\n 'With `status: fulfilled`, the units this shipment covers: `[{ lineItemId, quantity }]`, where `lineItemId` is the line’s index. Omitted, the shipment covers everything still to ship. More than is left is `409 conflict` (`code: \"over_fulfilled\"`). Send an `Idempotency-Key` header so a retried partial shipment is recorded once.',\n items: { type: 'object', additionalProperties: true },\n },\n notify: bool('Whether the buyer is told about this shipment. Defaults to true.'),\n },\n writeRequired: ['status'],\n fields: {\n id: str('Order id.'),\n object: OBJECT_FIELD('order'),\n number: int('Human-facing order number.'),\n status: str('Order status.'),\n channel: str('`online` by default. Older orders carry no stored value, so `?channel=online` drops them after the read.'),\n currency: str('ISO 4217 code.'),\n customerEmail: nullable(str('Customer email.')),\n customerName: nullable(str('Customer name.')),\n lineItems: { type: 'array', description: 'What was bought.', items: { type: 'object', additionalProperties: true } },\n totals: objectOf('Money totals, in the smallest unit of `currency`. `extrasCents` is the optional lines the buyer added at checkout, inside `totalCents` and outside `itemsCents`.'),\n extras: { type: 'array', description: 'Optional lines the buyer added at checkout, such as package protection: `[{ id, pluginId, key, label, amountCents, quoteRef }]`. Empty when there were none.', items: { type: 'object', additionalProperties: true } },\n refundedCents: int('Amount refunded so far.'),\n disputed: bool('Whether a chargeback is open.'),\n taxMode: nullable(str('The tax regime: `stripe-automatic` (Stripe Tax, collected and remitted by the platform as marketplace facilitator), `manual` (your own rate) or `none`. `null` on an order from before it was recorded.')),\n taxEngine: nullable(objectOf('The tax service you connected, when one was asked for this sale’s tax: `provider` (`avalara` or `taxjar`), `providerLabel`, `status` (`quoted` when its tax was charged, `fallback` when it did not answer and your own rate was charged), `reason` (`timeout` or `error` on a fallback) and `sandbox`. `null` when no service was asked.')),\n shippingAddress: ADDRESS(),\n couponCode: nullable(str('Coupon applied.')),\n fulfillments: { type: 'array', description: 'Shipments and deliveries.', items: { type: 'object', additionalProperties: true } },\n created: STAMPS.created,\n },\n ops: [\n { path: '/v1/sites/{siteId}/orders', method: 'get', operationId: 'listOrders', summary: 'List orders', list: true, returns: 'Order', filters: [q('channel', '`online` is a default rather than a stored value, so filtering on it drops older orders after the read.'), q('status', 'Order status.')], pathParams: [{ name: 'siteId', description: 'Site id.' }] },\n { path: '/v1/sites/{siteId}/orders/{orderId}', method: 'get', operationId: 'getOrder', summary: 'Retrieve an order', returns: 'Order', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'orderId', description: 'Order id.' }] },\n { path: '/v1/sites/{siteId}/orders/{orderId}', method: 'patch', operationId: 'updateOrder', summary: 'Move an order’s status', accepts: 'OrderWrite', returns: 'Order', description: 'An illegal transition is `409 conflict` (`code: \"order_transition\"`), and the message names the status it is in.', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'orderId', description: 'Order id.' }] },\n ],\n}\n"],"names":["booleanField","bool","integerField","int","nullableField","nullable","objectKindField","OBJECT_FIELD","openObjectField","objectOf","postalAddressField","ADDRESS","queryParam","q","RECORD_STAMPS","STAMPS","stringField","str","stringListField","strList","PRODUCTS_API_V1_DESCRIPTION","tag","description","schemaName","required","fields","id","object","name","slug","type","status","tags","categoryIds","mediaUrls","options","items","additionalProperties","variants","inventory","subscription","ops","path","method","operationId","summary","list","returns","pathParams","ORDERS_API_V1_DESCRIPTION","writable","writeOnly","enum","carrier","trackingNumber","trackingUrl","lineItems","notify","writeRequired","number","channel","currency","customerEmail","customerName","totals","extras","refundedCents","disputed","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O,sBAAsB;YAAK;QAAE;QAC/HoC,SAAS1D,OAAO0D,OAAO;IACzB;IACAhC,KAAK;QACH;YAAEC,MAAM;YAA6BC,QAAQ;YAAOC,aAAa;YAAcC,SAAS;YAAeC,MAAM;YAAMC,SAAS;YAAS2B,SAAS;gBAAC7D,EAAE,WAAW;gBAA4GA,EAAE,UAAU;aAAiB;YAAEmC,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;aAAE;QAAC;QACjW;YAAEoB,MAAM;YAAuCC,QAAQ;YAAOC,aAAa;YAAYC,SAAS;YAAqBE,SAAS;YAASC,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;gBAAG;oBAAEM,MAAM;oBAAWN,aAAa;gBAAY;aAAE;QAAC;QAChP;YAAEoB,MAAM;YAAuCC,QAAQ;YAASC,aAAa;YAAeC,SAAS;YAA0B8B,SAAS;YAAc5B,SAAS;YAASzB,aAAa;YAAoH0B,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;gBAAG;oBAAEM,MAAM;oBAAWN,aAAa;gBAAY;aAAE;QAAC;KACnZ;AACH,EAAC"}
@@ -0,0 +1,67 @@
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
+ /**
18
+ * The public order shape from an order's data (AGL-3611): the same object the
19
+ * API returns, so an order event and an outbound webhook carry exactly what
20
+ * `GET /v1/sites/{id}/orders/{id}` would.
21
+ */
22
+ export declare function orderViewFromData(id: string, data: Record<string, any>): {
23
+ id: string;
24
+ object: string;
25
+ number: number;
26
+ status: string;
27
+ channel: string;
28
+ currency: string;
29
+ customerEmail: any;
30
+ customerName: any;
31
+ lineItems: unknown;
32
+ totals: {
33
+ itemsCents: number;
34
+ shippingCents: number;
35
+ taxCents: number;
36
+ discountCents: number;
37
+ totalCents: number;
38
+ feeCents: number;
39
+ extrasCents: number;
40
+ };
41
+ extras: {
42
+ id: string;
43
+ pluginId: string;
44
+ key: string;
45
+ label: string;
46
+ amountCents: number;
47
+ quoteRef: string;
48
+ }[];
49
+ refundedCents: number;
50
+ taxMode: string;
51
+ taxEngine: import("../../model/commerce-tax-engine").OrderTaxEngineStamp;
52
+ disputed: boolean;
53
+ shippingAddress: unknown;
54
+ couponCode: any;
55
+ fulfillments: {
56
+ id: unknown;
57
+ lineItemIds: unknown[];
58
+ lines: import("../../model").OrderFulfillmentLine[];
59
+ status: string;
60
+ carrier: unknown;
61
+ trackingNumber: unknown;
62
+ trackingUrl: string;
63
+ labelUrl: unknown;
64
+ at: string;
65
+ }[];
66
+ created: unknown;
67
+ };
@@ -0,0 +1,120 @@
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 { serialize } from "@aglyn/tenant-data-admin/server/api-v1-kit";
17
+ import { fulfillmentLineQuantities } from "../../model/order-fulfillment.js";
18
+ import { fulfillmentTrackingUrl } from "../../model/tracking-url.js";
19
+ import { orderTaxEngineView } from "../../model/commerce-tax-engine.js";
20
+ /**
21
+ * The public order shape from an order's data (AGL-3611): the same object the
22
+ * API returns, so an order event and an outbound webhook carry exactly what
23
+ * `GET /v1/sites/{id}/orders/{id}` would.
24
+ */ export function orderViewFromData(id, data) {
25
+ var _data_totals, _data_amountCents, _data_feeCents, _data_status, _data_channel, _data_customerEmail, _data_customerName, _data_lineItems, _totals_itemsCents, _totals_shippingCents, _totals_taxCents, _totals_discountCents, _totals_extrasCents, _data_refundedCents, _serialize, _data_couponCode, _serialize1;
26
+ const totals = (_data_totals = data.totals) != null ? _data_totals : {};
27
+ const legacyTotal = Number((_data_amountCents = data.amountCents) != null ? _data_amountCents : NaN);
28
+ const totalCents = Number.isFinite(Number(totals.totalCents)) ? Number(totals.totalCents) : Number.isFinite(legacyTotal) ? legacyTotal : null;
29
+ const legacyFee = Number((_data_feeCents = data.feeCents) != null ? _data_feeCents : NaN);
30
+ return {
31
+ id,
32
+ object: 'order',
33
+ number: typeof data.number === 'number' ? data.number : null,
34
+ status: (_data_status = data.status) != null ? _data_status : null,
35
+ channel: (_data_channel = data.channel) != null ? _data_channel : 'online',
36
+ currency: 'usd',
37
+ customerEmail: (_data_customerEmail = data.customerEmail) != null ? _data_customerEmail : null,
38
+ customerName: (_data_customerName = data.customerName) != null ? _data_customerName : null,
39
+ lineItems: serialize((_data_lineItems = data.lineItems) != null ? _data_lineItems : []),
40
+ totals: {
41
+ itemsCents: Number((_totals_itemsCents = totals.itemsCents) != null ? _totals_itemsCents : 0),
42
+ shippingCents: Number((_totals_shippingCents = totals.shippingCents) != null ? _totals_shippingCents : 0),
43
+ taxCents: Number((_totals_taxCents = totals.taxCents) != null ? _totals_taxCents : 0),
44
+ discountCents: Number((_totals_discountCents = totals.discountCents) != null ? _totals_discountCents : 0),
45
+ totalCents,
46
+ // The Connect application fee. NOT subtracted from `totalCents` — it is
47
+ // Aglyn's cut of a total the shopper already paid in full, so a client
48
+ // that nets it out of revenue would understate what it collected.
49
+ feeCents: Number.isFinite(Number(totals.feeCents)) ? Number(totals.feeCents) : Number.isFinite(legacyFee) ? legacyFee : 0,
50
+ // Optional lines the buyer added at checkout (AGL-3635), inside
51
+ // `totalCents` and outside `itemsCents`.
52
+ extrasCents: Number((_totals_extrasCents = totals.extrasCents) != null ? _totals_extrasCents : 0) || 0
53
+ },
54
+ // What those lines were and whose offer each was: the fact a plugin that
55
+ // insures a parcel reads off `order.paid` to know it was bought.
56
+ extras: (Array.isArray(data.extras) ? data.extras : []).filter((entry)=>entry && typeof entry.id === 'string').map((entry)=>{
57
+ var _entry_pluginId, _entry_key, _entry_label, _entry_amountCents;
58
+ return {
59
+ id: String(entry.id),
60
+ pluginId: String((_entry_pluginId = entry.pluginId) != null ? _entry_pluginId : ''),
61
+ key: String((_entry_key = entry.key) != null ? _entry_key : ''),
62
+ label: String((_entry_label = entry.label) != null ? _entry_label : ''),
63
+ amountCents: Number((_entry_amountCents = entry.amountCents) != null ? _entry_amountCents : 0) || 0,
64
+ quoteRef: typeof entry.quoteRef === 'string' ? entry.quoteRef : null
65
+ };
66
+ }),
67
+ // Money already handed back, for any reason. A chargeback lands here too,
68
+ // so `refundedCents > 0` does not by itself mean the merchant chose it.
69
+ refundedCents: Number((_data_refundedCents = data.refundedCents) != null ? _data_refundedCents : 0),
70
+ // Who the tax was charged under (AGL-3614): `stripe-automatic` tax is
71
+ // Aglyn's to remit as marketplace facilitator and never reaches the
72
+ // merchant's account, which a ledger posting the sale has to know. An
73
+ // order from before the regime was recorded says `null`, never a guess.
74
+ taxMode: typeof data.taxMode === 'string' && data.taxMode ? data.taxMode : null,
75
+ // The merchant's own tax service (AGL-3631): which one priced the sale, or
76
+ // that it was asked and the store's own rates were charged instead
77
+ // (`status: 'fallback'`). `null` when no service was asked. The regime is
78
+ // still `taxMode` — a service the merchant connected answers for tax the
79
+ // merchant remits.
80
+ taxEngine: orderTaxEngineView(data.taxEngine),
81
+ disputed: Boolean(data.dispute),
82
+ shippingAddress: (_serialize = serialize(data.shippingAddress)) != null ? _serialize : null,
83
+ couponCode: (_data_couponCode = data.couponCode) != null ? _data_couponCode : null,
84
+ // Shipment records — the half of fulfilment an integration can use
85
+ // without a write (AGL-2460). `status` says an order is `fulfilled`; it
86
+ // does not say which carrier took it or under what tracking number, so a
87
+ // 3PL or accounting reconcile could see THAT an order shipped and never
88
+ // WHICH shipment it was. The console's order dialog shows both, and an
89
+ // order that has been shipped twice (a split shipment) is indistinguish-
90
+ // able from one shipped once when only the status is published.
91
+ //
92
+ // `atMs` is a number of milliseconds, not a Firestore Timestamp, so
93
+ // `serialize` passes it through untouched. It is republished as `at` in
94
+ // ISO 8601 to match `created` and every other time this API emits: one
95
+ // object publishing two time formats is a bug an integrator finds late,
96
+ // in their own timezone conversion, and blames on their own code.
97
+ fulfillments: (Array.isArray(data.fulfillments) ? data.fulfillments : []).map((entry)=>{
98
+ var _id, _carrier, _trackingNumber, _labelUrl;
99
+ const atMs = Number((entry != null ? entry : {}).atMs);
100
+ return {
101
+ id: (_id = (entry != null ? entry : {}).id) != null ? _id : null,
102
+ lineItemIds: Array.isArray((entry != null ? entry : {}).lineItemIds) ? entry.lineItemIds : [],
103
+ // Units per line (AGL-3611); a fulfillment recorded before
104
+ // quantities shipped every unit of the lines it names.
105
+ lines: fulfillmentLineQuantities({
106
+ lineItems: Array.isArray(data.lineItems) ? data.lineItems : []
107
+ }, entry != null ? entry : {}),
108
+ status: (entry != null ? entry : {}).status === 'cancelled' ? 'cancelled' : 'active',
109
+ carrier: (_carrier = (entry != null ? entry : {}).carrier) != null ? _carrier : null,
110
+ trackingNumber: (_trackingNumber = (entry != null ? entry : {}).trackingNumber) != null ? _trackingNumber : null,
111
+ trackingUrl: fulfillmentTrackingUrl(entry != null ? entry : {}),
112
+ labelUrl: (_labelUrl = (entry != null ? entry : {}).labelUrl) != null ? _labelUrl : null,
113
+ at: Number.isFinite(atMs) ? new Date(atMs).toISOString() : null
114
+ };
115
+ }),
116
+ created: (_serialize1 = serialize(data.createdAt)) != null ? _serialize1 : null
117
+ };
118
+ }
119
+
120
+ //# sourceMappingURL=order-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/server/api-v1/order-view.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 { serialize } from '@aglyn/tenant-data-admin/server/api-v1-kit'\nimport { fulfillmentLineQuantities } from '../../model/order-fulfillment'\nimport { fulfillmentTrackingUrl } from '../../model/tracking-url'\nimport { orderTaxEngineView } from '../../model/commerce-tax-engine'\n\n/**\n * The public order shape from an order's data (AGL-3611): the same object the\n * API returns, so an order event and an outbound webhook carry exactly what\n * `GET /v1/sites/{id}/orders/{id}` would.\n */\nexport function orderViewFromData(id: string, data: Record<string, any>) {\n const totals = (data.totals ?? {}) as Record<string, unknown>\n const legacyTotal = Number(data.amountCents ?? NaN)\n const totalCents = Number.isFinite(Number(totals.totalCents))\n ? Number(totals.totalCents)\n : Number.isFinite(legacyTotal)\n ? legacyTotal\n : null\n const legacyFee = Number(data.feeCents ?? NaN)\n return {\n id,\n object: 'order',\n number: typeof data.number === 'number' ? data.number : null,\n status: (data.status as string) ?? null,\n channel: (data.channel as string) ?? 'online',\n currency: 'usd',\n customerEmail: data.customerEmail ?? null,\n customerName: data.customerName ?? null,\n lineItems: serialize(data.lineItems ?? []),\n totals: {\n itemsCents: Number(totals.itemsCents ?? 0),\n shippingCents: Number(totals.shippingCents ?? 0),\n taxCents: Number(totals.taxCents ?? 0),\n discountCents: Number(totals.discountCents ?? 0),\n totalCents,\n // The Connect application fee. NOT subtracted from `totalCents` — it is\n // Aglyn's cut of a total the shopper already paid in full, so a client\n // that nets it out of revenue would understate what it collected.\n feeCents: Number.isFinite(Number(totals.feeCents))\n ? Number(totals.feeCents)\n : Number.isFinite(legacyFee)\n ? legacyFee\n : 0,\n // Optional lines the buyer added at checkout (AGL-3635), inside\n // `totalCents` and outside `itemsCents`.\n extrasCents: Number(totals.extrasCents ?? 0) || 0,\n },\n // What those lines were and whose offer each was: the fact a plugin that\n // insures a parcel reads off `order.paid` to know it was bought.\n extras: (Array.isArray(data.extras) ? data.extras : [])\n .filter((entry: Record<string, unknown>) => entry && typeof entry.id === 'string')\n .map((entry: Record<string, unknown>) => ({\n id: String(entry.id),\n pluginId: String(entry.pluginId ?? ''),\n key: String(entry.key ?? ''),\n label: String(entry.label ?? ''),\n amountCents: Number(entry.amountCents ?? 0) || 0,\n quoteRef: typeof entry.quoteRef === 'string' ? entry.quoteRef : null,\n })),\n // Money already handed back, for any reason. A chargeback lands here too,\n // so `refundedCents > 0` does not by itself mean the merchant chose it.\n refundedCents: Number(data.refundedCents ?? 0),\n // Who the tax was charged under (AGL-3614): `stripe-automatic` tax is\n // Aglyn's to remit as marketplace facilitator and never reaches the\n // merchant's account, which a ledger posting the sale has to know. An\n // order from before the regime was recorded says `null`, never a guess.\n taxMode: typeof data.taxMode === 'string' && data.taxMode ? data.taxMode : null,\n // The merchant's own tax service (AGL-3631): which one priced the sale, or\n // that it was asked and the store's own rates were charged instead\n // (`status: 'fallback'`). `null` when no service was asked. The regime is\n // still `taxMode` — a service the merchant connected answers for tax the\n // merchant remits.\n taxEngine: orderTaxEngineView(data.taxEngine),\n disputed: Boolean(data.dispute),\n shippingAddress: serialize(data.shippingAddress) ?? null,\n couponCode: data.couponCode ?? null,\n // Shipment records — the half of fulfilment an integration can use\n // without a write (AGL-2460). `status` says an order is `fulfilled`; it\n // does not say which carrier took it or under what tracking number, so a\n // 3PL or accounting reconcile could see THAT an order shipped and never\n // WHICH shipment it was. The console's order dialog shows both, and an\n // order that has been shipped twice (a split shipment) is indistinguish-\n // able from one shipped once when only the status is published.\n //\n // `atMs` is a number of milliseconds, not a Firestore Timestamp, so\n // `serialize` passes it through untouched. It is republished as `at` in\n // ISO 8601 to match `created` and every other time this API emits: one\n // object publishing two time formats is a bug an integrator finds late,\n // in their own timezone conversion, and blames on their own code.\n fulfillments: (Array.isArray(data.fulfillments) ? data.fulfillments : []).map(\n (entry: Record<string, unknown>) => {\n const atMs = Number((entry ?? {}).atMs)\n return {\n id: (entry ?? {}).id ?? null,\n lineItemIds: Array.isArray((entry ?? {}).lineItemIds)\n ? (entry as { lineItemIds: unknown[] }).lineItemIds\n : [],\n // Units per line (AGL-3611); a fulfillment recorded before\n // quantities shipped every unit of the lines it names.\n lines: fulfillmentLineQuantities(\n { lineItems: Array.isArray(data.lineItems) ? data.lineItems : [] },\n (entry ?? {}) as never,\n ),\n status: (entry ?? {}).status === 'cancelled' ? 'cancelled' : 'active',\n carrier: (entry ?? {}).carrier ?? null,\n trackingNumber: (entry ?? {}).trackingNumber ?? null,\n trackingUrl: fulfillmentTrackingUrl((entry ?? {}) as never),\n labelUrl: (entry ?? {}).labelUrl ?? null,\n at: Number.isFinite(atMs) ? new Date(atMs).toISOString() : null,\n }\n },\n ),\n created: serialize(data.createdAt) ?? null,\n }\n}\n\n"],"names":["serialize","fulfillmentLineQuantities","fulfillmentTrackingUrl","orderTaxEngineView","orderViewFromData","id","data","totals","legacyTotal","Number","amountCents","NaN","totalCents","isFinite","legacyFee","feeCents","object","number","status","channel","currency","customerEmail","customerName","lineItems","itemsCents","shippingCents","taxCents","discountCents","extrasCents","extras","Array","isArray","filter","entry","map","String","pluginId","key","label","quoteRef","refundedCents","taxMode","taxEngine","disputed","Boolean","dispute","shippingAddress","couponCode","fulfillments","atMs","lineItemIds","lines","carrier","trackingNumber","trackingUrl","labelUrl","at","Date","toISOString","created","createdAt"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,SAAS,QAAQ,6CAA4C;AACtE,SAASC,yBAAyB,QAAQ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C,cAAc,GAAE,kBAAA,CAACpB,gBAAAA,QAAS,CAAC,GAAGoB,cAAc,YAA5B,kBAAgC;gBAChDC,aAAapD,uBAAwB+B,gBAAAA,QAAS,CAAC;gBAC/CsB,QAAQ,GAAE,YAAA,CAACtB,gBAAAA,QAAS,CAAC,GAAGsB,QAAQ,YAAtB,YAA0B;gBACpCC,IAAI/C,OAAOI,QAAQ,CAACoC,QAAQ,IAAIQ,KAAKR,MAAMS,WAAW,KAAK;YAC7D;QACF;QAEFC,OAAO,GAAE3D,cAAAA,UAAUM,KAAKsD,SAAS,aAAxB5D,cAA6B;IACxC;AACF"}
@@ -19,6 +19,7 @@ import { ApiErrors, apiJson, listResponse } from "@aglyn/tenant-data-admin";
19
19
  import { paginate, readJsonBody, requireScope, serialize } from "@aglyn/tenant-data-admin/server/api-v1-kit";
20
20
  import { BUNDLE_ID } from "../../constants/bundle-common.js";
21
21
  import { recordOrderShipment } from "../fulfill-order.js";
22
+ import { orderViewFromData } from "./order-view.js";
22
23
  /**
23
24
  * A site's orders and products on the customer REST API,
24
25
  * `/v1/sites/{siteId}/orders/…` and `/v1/sites/{siteId}/products/…`
@@ -61,66 +62,8 @@ function hostRef(ctx, hostId) {
61
62
  * for the same reason the console's list does — an absent channel is a
62
63
  * pre-channel order, not an unknown one.
63
64
  */ function orderView(doc) {
64
- var _doc_data, _data_totals, _data_amountCents, _data_feeCents, _data_status, _data_channel, _data_customerEmail, _data_customerName, _data_lineItems, _totals_itemsCents, _totals_shippingCents, _totals_taxCents, _totals_discountCents, _data_refundedCents, _serialize, _data_couponCode, _serialize1;
65
- const data = (_doc_data = doc.data()) != null ? _doc_data : {};
66
- const totals = (_data_totals = data.totals) != null ? _data_totals : {};
67
- const legacyTotal = Number((_data_amountCents = data.amountCents) != null ? _data_amountCents : NaN);
68
- const totalCents = Number.isFinite(Number(totals.totalCents)) ? Number(totals.totalCents) : Number.isFinite(legacyTotal) ? legacyTotal : null;
69
- const legacyFee = Number((_data_feeCents = data.feeCents) != null ? _data_feeCents : NaN);
70
- return {
71
- id: doc.id,
72
- object: 'order',
73
- number: typeof data.number === 'number' ? data.number : null,
74
- status: (_data_status = data.status) != null ? _data_status : null,
75
- channel: (_data_channel = data.channel) != null ? _data_channel : 'online',
76
- currency: 'usd',
77
- customerEmail: (_data_customerEmail = data.customerEmail) != null ? _data_customerEmail : null,
78
- customerName: (_data_customerName = data.customerName) != null ? _data_customerName : null,
79
- lineItems: serialize((_data_lineItems = data.lineItems) != null ? _data_lineItems : []),
80
- totals: {
81
- itemsCents: Number((_totals_itemsCents = totals.itemsCents) != null ? _totals_itemsCents : 0),
82
- shippingCents: Number((_totals_shippingCents = totals.shippingCents) != null ? _totals_shippingCents : 0),
83
- taxCents: Number((_totals_taxCents = totals.taxCents) != null ? _totals_taxCents : 0),
84
- discountCents: Number((_totals_discountCents = totals.discountCents) != null ? _totals_discountCents : 0),
85
- totalCents,
86
- // The Connect application fee. NOT subtracted from `totalCents` — it is
87
- // Aglyn's cut of a total the shopper already paid in full, so a client
88
- // that nets it out of revenue would understate what it collected.
89
- feeCents: Number.isFinite(Number(totals.feeCents)) ? Number(totals.feeCents) : Number.isFinite(legacyFee) ? legacyFee : 0
90
- },
91
- // Money already handed back, for any reason. A chargeback lands here too,
92
- // so `refundedCents > 0` does not by itself mean the merchant chose it.
93
- refundedCents: Number((_data_refundedCents = data.refundedCents) != null ? _data_refundedCents : 0),
94
- disputed: Boolean(data.dispute),
95
- shippingAddress: (_serialize = serialize(data.shippingAddress)) != null ? _serialize : null,
96
- couponCode: (_data_couponCode = data.couponCode) != null ? _data_couponCode : null,
97
- // Shipment records — the half of fulfilment an integration can use
98
- // without a write (AGL-2460). `status` says an order is `fulfilled`; it
99
- // does not say which carrier took it or under what tracking number, so a
100
- // 3PL or accounting reconcile could see THAT an order shipped and never
101
- // WHICH shipment it was. The console's order dialog shows both, and an
102
- // order that has been shipped twice (a split shipment) is indistinguish-
103
- // able from one shipped once when only the status is published.
104
- //
105
- // `atMs` is a number of milliseconds, not a Firestore Timestamp, so
106
- // `serialize` passes it through untouched. It is republished as `at` in
107
- // ISO 8601 to match `created` and every other time this API emits: one
108
- // object publishing two time formats is a bug an integrator finds late,
109
- // in their own timezone conversion, and blames on their own code.
110
- fulfillments: (Array.isArray(data.fulfillments) ? data.fulfillments : []).map((entry)=>{
111
- var _id, _carrier, _trackingNumber, _trackingUrl;
112
- const atMs = Number((entry != null ? entry : {}).atMs);
113
- return {
114
- id: (_id = (entry != null ? entry : {}).id) != null ? _id : null,
115
- lineItemIds: Array.isArray((entry != null ? entry : {}).lineItemIds) ? entry.lineItemIds : [],
116
- carrier: (_carrier = (entry != null ? entry : {}).carrier) != null ? _carrier : null,
117
- trackingNumber: (_trackingNumber = (entry != null ? entry : {}).trackingNumber) != null ? _trackingNumber : null,
118
- trackingUrl: (_trackingUrl = (entry != null ? entry : {}).trackingUrl) != null ? _trackingUrl : null,
119
- at: Number.isFinite(atMs) ? new Date(atMs).toISOString() : null
120
- };
121
- }),
122
- created: (_serialize1 = serialize(data.createdAt)) != null ? _serialize1 : null
123
- };
65
+ var _doc_data;
66
+ return orderViewFromData(doc.id, (_doc_data = doc.data()) != null ? _doc_data : {});
124
67
  }
125
68
  export async function handleOrders(request, ctx, segments, url) {
126
69
  const [, hostId, , orderId] = segments;
@@ -183,6 +126,14 @@ export async function handleOrders(request, ctx, segments, url) {
183
126
  'fulfilled',
184
127
  'delivered'
185
128
  ];
129
+ /** The keys a PATCH may carry (AGL-3611 added the last three). */ const ORDER_WRITABLE_KEYS = [
130
+ 'status',
131
+ 'carrier',
132
+ 'trackingNumber',
133
+ 'trackingUrl',
134
+ 'lineItems',
135
+ 'notify'
136
+ ];
186
137
  /**
187
138
  * Transitions that exist in the commerce model and are DELIBERATELY not
188
139
  * reachable here — refused by name with a 400 that says why, never silently
@@ -241,16 +192,16 @@ export async function handleOrders(request, ctx, segments, url) {
241
192
  * AND returns the same `200` with the same order body — the contract
242
193
  * `updateRecord`, `updateContact` and `updateFormSubmission` are held to.
243
194
  */ async function updateOrder(request, ctx, hostId, orderId) {
244
- var _body_status, _body_carrier, _body_trackingNumber;
195
+ var _body_status, _body_carrier, _body_trackingNumber, _request_headers_get;
245
196
  const body = await readJsonBody(request);
246
- const unknown = Object.keys(body).filter((key)=>key !== 'status' && key !== 'carrier' && key !== 'trackingNumber');
197
+ const unknown = Object.keys(body).filter((key)=>!ORDER_WRITABLE_KEYS.includes(key));
247
198
  if (unknown.length > 0) {
248
199
  // Named, not dropped — the `updateFormSubmission` / `updateContact` rule.
249
200
  // A silently ignored `trackingUrl` here reads as "we recorded your
250
201
  // shipment as you described it" when half of it went nowhere, and the
251
202
  // caller is a warehouse system that will never look again.
252
203
  return ApiErrors.badRequest({
253
- message: 'Only `status`, `carrier` and `trackingNumber` can be set on an order',
204
+ message: 'Only `status`, `carrier`, `trackingNumber`, `trackingUrl`, `lineItems` and `notify` can be set on an order',
254
205
  code: 'validation_failed',
255
206
  fields: Object.fromEntries(unknown.map((key)=>[
256
207
  key,
@@ -285,6 +236,26 @@ export async function handleOrders(request, ctx, segments, url) {
285
236
  // used to stuff an order document through a door the console keeps narrow.
286
237
  const carrier = String((_body_carrier = body.carrier) != null ? _body_carrier : '').slice(0, 40);
287
238
  const trackingNumber = String((_body_trackingNumber = body.trackingNumber) != null ? _body_trackingNumber : '').slice(0, 60);
239
+ // Partial shipments (AGL-3611): `lineItems: [{ lineItemId, quantity }]`.
240
+ // Absent keeps the old meaning, everything still to ship.
241
+ let lineItems;
242
+ if (body.lineItems !== undefined) {
243
+ if (status !== 'fulfilled' || !Array.isArray(body.lineItems) || body.lineItems.length === 0) {
244
+ return ApiErrors.badRequest({
245
+ message: 'Order failed validation',
246
+ code: 'validation_failed',
247
+ fields: {
248
+ lineItems: status !== 'fulfilled' ? 'Only a `fulfilled` update names line items' : 'Must be a non-empty array of { lineItemId, quantity }'
249
+ },
250
+ headers: ctx.headers
251
+ });
252
+ }
253
+ lineItems = body.lineItems.slice(0, 500).map((entry)=>({
254
+ lineItemId: Number(entry == null ? void 0 : entry.lineItemId),
255
+ quantity: Number(entry == null ? void 0 : entry.quantity)
256
+ }));
257
+ }
258
+ const idempotencyKey = (_request_headers_get = request.headers.get('idempotency-key')) != null ? _request_headers_get : undefined;
288
259
  // Gate 4: this plugin, on for this site.
289
260
  const hostSnap = await hostRef(ctx, hostId).get();
290
261
  if (!isHostPluginEnabled(ctx.org, hostSnap.data(), BUNDLE_ID)) {
@@ -293,13 +264,35 @@ export async function handleOrders(request, ctx, segments, url) {
293
264
  headers: ctx.headers
294
265
  });
295
266
  }
296
- const outcome = await recordOrderShipment({
267
+ const outcome = await recordOrderShipment(_extends({
297
268
  hostId,
298
269
  orderId,
299
270
  to: status,
300
271
  carrier,
301
272
  trackingNumber
302
- });
273
+ }, lineItems ? {
274
+ lineItems
275
+ } : {}, typeof body.trackingUrl === 'string' ? {
276
+ trackingUrl: body.trackingUrl
277
+ } : {}, body.notify === false ? {
278
+ notify: false
279
+ } : {}, idempotencyKey ? {
280
+ idempotencyKey
281
+ } : {}));
282
+ if (outcome.outcome === 'invalid_lines') {
283
+ return outcome.problem.problem === 'over_fulfilled' ? ApiErrors.conflict({
284
+ message: outcome.message,
285
+ code: 'over_fulfilled',
286
+ headers: ctx.headers
287
+ }) : ApiErrors.badRequest({
288
+ message: 'Order failed validation',
289
+ code: 'validation_failed',
290
+ fields: {
291
+ lineItems: outcome.message
292
+ },
293
+ headers: ctx.headers
294
+ });
295
+ }
303
296
  if (outcome.outcome === 'no_such_order') {
304
297
  return ApiErrors.notFound({
305
298
  message: 'No such order',