@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,483 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ import { randomBytes, timingSafeEqual } from "crypto";
18
+ import { PLATFORM_BRAND_NAME } from "@aglyn/aglyn/app-utils/platform-brand";
19
+ import { readClientIp } from "@aglyn/aglyn/app-utils/request-ip";
20
+ import { needsReseal, openSecret, sealSecret } from "@aglyn/shared-util-tools/secret-box";
21
+ import { consumeRateLimit, firebaseAdmin } from "@aglyn/tenant-data-admin";
22
+ import * as CommerceModel from "../model/index.js";
23
+ import { recordOrderShipment } from "./fulfill-order.js";
24
+ import { readCommerceSecretKeyring } from "./order-webhooks.js";
25
+ import { connectorHostIdOf, connectorSiteRefusal, connectorText as text, digestSecret, requestIsSecure } from "./shipping-connector-gates.js";
26
+ export { digestSecret, requestIsSecure } from "./shipping-connector-gates.js";
27
+ // lockdown-423: handled — the route asks `lockdownRefusal` itself (through `connectorSiteRefusal`), for the org and site its credentials name, before any read.
28
+ /*
29
+ * SHIPSTATION'S CUSTOM STORE ENDPOINT (AGL-3613):
30
+ * `/api/commerce/shipstation/{hostId}`, GET `?action=export` and POST
31
+ * `?action=shipnotify` — the feed and the notice are pure data in
32
+ * `model/shipstation.ts`.
33
+ *
34
+ * ## A machine's route, with every gate of its own
35
+ *
36
+ * ShipStation calls from its own servers with HTTP Basic credentials and
37
+ * names no member, so the route is registered as a MACHINE's
38
+ * (`machine: true`): the dispatcher skips its per-site enablement, release
39
+ * and write-limit gates, and this route answers each of them itself, for
40
+ * the site its URL names, AFTER the credentials are proven — an unproven
41
+ * caller learns nothing about the site, not even whether commerce is on.
42
+ *
43
+ * - HTTPS only, outside development: the credentials ride every request.
44
+ * - A per-site, per-address budget (`SHIPSTATION_RATE_LIMIT`); ShipStation
45
+ * polls from a handful of addresses shared by every store it serves, which
46
+ * is why the dispatcher's address-only bucket was the wrong one.
47
+ * - Credentials minted per site by the console card. The password is sealed
48
+ * with the shared secret box under commerce's keyring
49
+ * (`readCommerceSecretKeyring`), bound to its site by the seal's context,
50
+ * so a site's admin can show it again and a copied document opens for no
51
+ * other site. A request's pair is compared as fixed-length digests in
52
+ * constant time.
53
+ * - The site's commerce must be on, entitled by the plan and released for
54
+ * the org; a security or manual lockdown refuses.
55
+ *
56
+ * ## Which orders, and why a query
57
+ *
58
+ * The feed answers every order MODIFIED in ShipStation's window, whatever
59
+ * its status — a cancel must reach ShipStation or a merchant ships it. Every
60
+ * order writer stamps `updatedAtMs`, every creator stamps `requiresShipping`
61
+ * (`withOrderListFields`), and the feed is ONE indexed query on the pair:
62
+ * `(requiresShipping ==, updatedAtMs range)`. Pages follow a stored cursor,
63
+ * so page 5 does not re-read pages 1 to 4; a page asked out of order falls
64
+ * back to an offset.
65
+ *
66
+ * ## The notice is a shipment, recorded once
67
+ *
68
+ * A ShipNotice becomes a fulfillment through `recordOrderShipment` — the
69
+ * console's own transaction, which also emails the buyer — for the items it
70
+ * names, bounded by what is left to ship. Its tracking number is the
71
+ * parcel's identity: the same number on the same order is answered
72
+ * `already` and writes nothing, however often ShipStation retries or
73
+ * whether the merchant typed it in first.
74
+ */ /** Where each site's credentials are kept: server-only, every client denied. */ export const SHIPSTATION_CONNECTIONS = 'commerceShipStationConnections';
75
+ /** Requests per minute, per site and per calling address. */ export const SHIPSTATION_RATE_LIMIT = 120;
76
+ /** The largest ShipNotice body read. A notice is a few kilobytes. */ export const SHIPNOTICE_MAX_BYTES = 256 * 1024;
77
+ /** A fresh username and password for a site. */ export function mintShipStationCredentials() {
78
+ return {
79
+ username: `aglyn-${randomBytes(6).toString('hex')}`,
80
+ password: randomBytes(24).toString('base64url')
81
+ };
82
+ }
83
+ /** What binds a sealed password to its site: a copy opens for no other. */ export const shipStationSealContext = (hostId)=>`${SHIPSTATION_CONNECTIONS}/${hostId}#password`;
84
+ /** The password sealed for a site, with the id of the key that sealed it. */ export function sealShipStationPassword(hostId, password, keyring) {
85
+ return {
86
+ sealedPassword: sealSecret(password, keyring.current, {
87
+ context: shipStationSealContext(hostId)
88
+ }),
89
+ passwordKeyId: keyring.current.id
90
+ };
91
+ }
92
+ /**
93
+ * A site's password in the clear, and whether it should be sealed again under
94
+ * the keyring's current key. `null` when it cannot be opened: no keyring, a
95
+ * key the ring no longer holds, or a document copied from another site.
96
+ */ export function openShipStationPassword(connection, keyring) {
97
+ if (!(connection == null ? void 0 : connection.sealedPassword) || !keyring) return null;
98
+ try {
99
+ const opened = openSecret(connection.sealedPassword, keyring, {
100
+ context: shipStationSealContext(connection.hostId)
101
+ });
102
+ return {
103
+ password: opened.plaintext,
104
+ reseal: needsReseal(opened, keyring)
105
+ };
106
+ } catch (unused) {
107
+ return null;
108
+ }
109
+ }
110
+ /** The username and password of a Basic `Authorization` header, or `null`. */ export function readBasicAuth(header) {
111
+ const value = String(header != null ? header : '');
112
+ const match = /^Basic\s+([A-Za-z0-9+/=_-]+)\s*$/i.exec(value);
113
+ if (!match) return null;
114
+ let decoded;
115
+ try {
116
+ decoded = Buffer.from(match[1], 'base64').toString('utf8');
117
+ } catch (unused) {
118
+ return null;
119
+ }
120
+ const colon = decoded.indexOf(':');
121
+ if (colon < 0) return null;
122
+ return {
123
+ username: decoded.slice(0, colon),
124
+ password: decoded.slice(colon + 1)
125
+ };
126
+ }
127
+ /**
128
+ * Whether the presented credentials are the stored ones. Both halves are
129
+ * compared, always, as fixed-length digests, so neither a wrong username nor
130
+ * a wrong password answers faster than the other. A password that could not
131
+ * be opened (`null`) matches nothing.
132
+ */ export function credentialsMatch(stored, presented) {
133
+ var _ref, _ref1, _ref2, _ref3;
134
+ const expectedUser = Buffer.from(digestSecret((_ref = stored == null ? void 0 : stored.username) != null ? _ref : '\u0000'), 'hex');
135
+ const expectedPass = Buffer.from(digestSecret((_ref1 = stored == null ? void 0 : stored.password) != null ? _ref1 : '\u0000'), 'hex');
136
+ const user = Buffer.from(digestSecret((_ref2 = presented == null ? void 0 : presented.username) != null ? _ref2 : ''), 'hex');
137
+ const pass = Buffer.from(digestSecret((_ref3 = presented == null ? void 0 : presented.password) != null ? _ref3 : ''), 'hex');
138
+ const userOk = timingSafeEqual(user, expectedUser);
139
+ const passOk = timingSafeEqual(pass, expectedPass);
140
+ return Boolean(stored && stored.password !== null && presented && userOk && passOk);
141
+ }
142
+ const unauthorized = ()=>text(401, `The ShipStation username or password is wrong. Copy them again from ${PLATFORM_BRAND_NAME}.`, {
143
+ 'www-authenticate': `Basic realm="${PLATFORM_BRAND_NAME.replace(/"/g, '')} ShipStation", charset="UTF-8"`
144
+ });
145
+ /**
146
+ * What the feed needs of each product a page names: every variant's weight,
147
+ * image and option choices, one `getAll` per page.
148
+ */ export async function shipStationProductsFor(hostRef, orders) {
149
+ const ids = [
150
+ ...new Set(orders.flatMap((order)=>{
151
+ var _order_lineItems;
152
+ return ((_order_lineItems = order.lineItems) != null ? _order_lineItems : []).map((line)=>line == null ? void 0 : line.productId);
153
+ }).filter((id)=>Boolean(id)))
154
+ ].filter((id)=>!id.includes('/'));
155
+ const products = {};
156
+ const collection = hostRef.collection('products');
157
+ for(let at = 0; at < ids.length; at += 100){
158
+ const docs = await hostRef.firestore.getAll(...ids.slice(at, at + 100).map((id)=>collection.doc(id)));
159
+ for (const doc of docs){
160
+ var _, _product_mediaUrls;
161
+ if (!doc.exists) continue;
162
+ const product = CommerceModel.liftLegacyProduct(doc.data());
163
+ const image = (_ = ((_product_mediaUrls = product.mediaUrls) != null ? _product_mediaUrls : [])[0]) != null ? _ : doc.get('imageUrl');
164
+ const variants = {};
165
+ const first = product.variants[0];
166
+ variants[''] = _extends({}, (first == null ? void 0 : first.weightGrams) ? {
167
+ grams: first.weightGrams
168
+ } : {}, image ? {
169
+ imageUrl: image
170
+ } : {});
171
+ for (const variant of product.variants){
172
+ variants[variant.id] = _extends({}, variant.weightGrams ? {
173
+ grams: variant.weightGrams
174
+ } : {}, variant.imageUrl || image ? {
175
+ imageUrl: variant.imageUrl || image
176
+ } : {}, variant.options && Object.keys(variant.options).length ? {
177
+ options: variant.options
178
+ } : {});
179
+ }
180
+ products[doc.id] = variants;
181
+ }
182
+ }
183
+ return products;
184
+ }
185
+ /** The window ShipStation asked for, or the sentence explaining why it cannot be read. */ export function readExportWindow(query) {
186
+ var _query_get;
187
+ const startMs = CommerceModel.parseShipStationDate(query.get('start_date'));
188
+ const endMs = CommerceModel.parseShipStationDate(query.get('end_date'));
189
+ if (startMs === null || endMs === null) {
190
+ return {
191
+ problem: 'start_date and end_date must be dates as MM/dd/yyyy HH:mm, in UTC.'
192
+ };
193
+ }
194
+ if (endMs < startMs) return {
195
+ problem: 'end_date is before start_date.'
196
+ };
197
+ if (endMs - startMs > CommerceModel.SHIPSTATION_MAX_WINDOW_MS) {
198
+ return {
199
+ problem: 'Ask for at most a year of orders at a time.'
200
+ };
201
+ }
202
+ const pageText = (_query_get = query.get('page')) != null ? _query_get : '1';
203
+ const page = /^\d{1,5}$/.test(pageText) ? Number(pageText) : NaN;
204
+ if (!Number.isInteger(page) || page < 1) return {
205
+ problem: 'page must be a whole number from 1.'
206
+ };
207
+ // A window's end is a minute, so the whole of its last minute is inside it.
208
+ return {
209
+ startMs,
210
+ endMs: endMs + 59999,
211
+ page
212
+ };
213
+ }
214
+ /** One page of the feed, for a site whose request is already proven. */ export async function shipStationExport(hostId, window, connection, options = {}) {
215
+ var _options_pageSize, _ref, _ref1, _last_get;
216
+ const firestore = firebaseAdmin.app().firestore();
217
+ const hostRef = firestore.collection('hosts').doc(hostId);
218
+ const connectionRef = firestore.collection(SHIPSTATION_CONNECTIONS).doc(hostId);
219
+ const pageSize = (_options_pageSize = options.pageSize) != null ? _options_pageSize : CommerceModel.SHIPSTATION_PAGE_SIZE;
220
+ const idPath = firebaseAdmin.firestore.FieldPath.documentId();
221
+ const base = hostRef.collection('orders').where('requiresShipping', '==', true).where('updatedAtMs', '>=', window.startMs).where('updatedAtMs', '<=', window.endMs);
222
+ const total = Number((await base.count().get()).data().count) || 0;
223
+ const pages = Math.max(1, Math.ceil(total / pageSize));
224
+ const ordered = base.orderBy('updatedAtMs', 'asc').orderBy(idPath, 'asc');
225
+ const key = `${window.startMs}|${window.endMs}`;
226
+ const cursor = connection.exportCursor;
227
+ const followsCursor = window.page > 1 && (cursor == null ? void 0 : cursor.key) === key && cursor.page === window.page - 1;
228
+ const query = window.page === 1 ? ordered : followsCursor ? ordered.startAfter(...(_ref = cursor == null ? void 0 : cursor.after) != null ? _ref : []) : ordered.offset((window.page - 1) * pageSize);
229
+ const snapshot = window.page > pages ? null : await query.limit(pageSize).get();
230
+ const docs = (_ref1 = snapshot == null ? void 0 : snapshot.docs) != null ? _ref1 : [];
231
+ const sources = docs.map((doc)=>{
232
+ var _doc_data;
233
+ return {
234
+ docId: doc.id,
235
+ order: (_doc_data = doc.data()) != null ? _doc_data : {}
236
+ };
237
+ }).filter((entry)=>CommerceModel.shipStationCanImport(entry.order));
238
+ const products = await shipStationProductsFor(hostRef, sources.map((entry)=>entry.order));
239
+ const xml = CommerceModel.shipStationOrdersXml(sources.map((entry)=>CommerceModel.shipStationOrderXml(entry, products)), pages);
240
+ const last = docs[docs.length - 1];
241
+ await connectionRef.set(_extends({
242
+ lastExportAtMs: Date.now()
243
+ }, last ? {
244
+ exportCursor: {
245
+ key,
246
+ page: window.page,
247
+ after: [
248
+ Number((_last_get = last.get('updatedAtMs')) != null ? _last_get : 0),
249
+ last.id
250
+ ]
251
+ }
252
+ } : {}), {
253
+ merge: true
254
+ }).catch((error)=>console.warn('shipstation: cursor not saved', hostId, error));
255
+ return {
256
+ xml,
257
+ pages,
258
+ orders: sources.length
259
+ };
260
+ }
261
+ /*==========================================
262
+ * SHIPNOTIFY
263
+ *=========================================*/ /** The order a notice names, found by its id first and its number second. */ async function findNoticeOrder(hostRef, notice) {
264
+ const orders = hostRef.collection('orders');
265
+ const byId = CommerceModel.parseShippingOrderRef(notice.orderId);
266
+ if ((byId == null ? void 0 : byId.id) && !byId.id.includes('/')) {
267
+ const doc = await orders.doc(byId.id).get();
268
+ if (doc.exists) return doc;
269
+ }
270
+ const ref = CommerceModel.parseShippingOrderRef(notice.orderNumber);
271
+ if (!ref) return null;
272
+ if (ref.number !== undefined) {
273
+ const matches = await orders.where('number', '==', ref.number).limit(2).get();
274
+ // Two orders under one number is a store this route cannot decide for.
275
+ if (matches.size === 1) return matches.docs[0];
276
+ if (matches.size > 1) return null;
277
+ }
278
+ if (ref.id && !ref.id.includes('/')) {
279
+ const doc = await orders.doc(ref.id).get();
280
+ if (doc.exists) return doc;
281
+ }
282
+ return null;
283
+ }
284
+ /**
285
+ * Records one ShipNotice as a fulfillment, once. Every connector that hands
286
+ * shipments back reads its own wire format into a `ShipNotice` and records
287
+ * it here, so the parcel-once rule, the bound by what is left and the
288
+ * shipped email are one implementation (AGL-3613, AGL-3633).
289
+ */ export async function recordShipNotice(hostId, notice, bodyDigest, options = {}) {
290
+ var _options_source, _ref, _notice_orderNumber, _doc_data;
291
+ const source = (_options_source = options.source) != null ? _options_source : 'shipstation';
292
+ const hostRef = firebaseAdmin.app().firestore().collection('hosts').doc(hostId);
293
+ const doc = await findNoticeOrder(hostRef, notice);
294
+ const label = (_ref = (_notice_orderNumber = notice.orderNumber) != null ? _notice_orderNumber : notice.orderId) != null ? _ref : '?';
295
+ if (!doc) return {
296
+ status: 404,
297
+ body: `${PLATFORM_BRAND_NAME} has no order ${label} on this site.`
298
+ };
299
+ const order = CommerceModel.liftLegacyOrder((_doc_data = doc.data()) != null ? _doc_data : {});
300
+ const carrier = CommerceModel.shipStationCarrierName(notice.carrier);
301
+ const trackingNumber = notice.trackingNumber;
302
+ if (trackingNumber && CommerceModel.fulfillmentWithTracking(order, trackingNumber)) {
303
+ return {
304
+ status: 200,
305
+ body: 'Already recorded.'
306
+ };
307
+ }
308
+ const named = CommerceModel.shipNoticeLines(order, notice.items);
309
+ let lineItems;
310
+ if (named.lines) {
311
+ var _merged_get;
312
+ if (!named.lines.length) {
313
+ return {
314
+ status: 400,
315
+ body: `None of the shipped items is on order ${label}: ${named.unknown.join(', ')}.`
316
+ };
317
+ }
318
+ // Bounded by what is left: ShipStation's copy of the order may predate a
319
+ // parcel the merchant shipped from Aglyn, and asking for more than
320
+ // remains would refuse the whole notice.
321
+ const remaining = new Map(CommerceModel.orderLineFulfillmentStates(order).map((state)=>[
322
+ state.lineItemId,
323
+ state.remainingQuantity
324
+ ]));
325
+ const merged = new Map();
326
+ for (const entry of named.lines)merged.set(entry.lineItemId, ((_merged_get = merged.get(entry.lineItemId)) != null ? _merged_get : 0) + entry.quantity);
327
+ lineItems = [
328
+ ...merged.entries()
329
+ ].map(([lineItemId, quantity])=>{
330
+ var _remaining_get;
331
+ return {
332
+ lineItemId,
333
+ quantity: Math.min(quantity, (_remaining_get = remaining.get(lineItemId)) != null ? _remaining_get : 0)
334
+ };
335
+ }).filter((entry)=>entry.quantity > 0);
336
+ if (!lineItems.length) return {
337
+ status: 200,
338
+ body: 'Nothing on this notice is left to ship; nothing recorded.'
339
+ };
340
+ }
341
+ const outcome = await recordOrderShipment(_extends({
342
+ hostId,
343
+ orderId: doc.id,
344
+ to: 'fulfilled',
345
+ carrier,
346
+ trackingNumber
347
+ }, lineItems ? {
348
+ lineItems
349
+ } : {}, {
350
+ // The parcel's identity: its tracking number, or — for a "mark as
351
+ // shipped" with none — the notice itself, so a redelivery is one parcel.
352
+ idempotencyKey: trackingNumber ? `${source}:${CommerceModel.normalizeTrackingNumber(trackingNumber)}` : `${source}-notice:${bodyDigest}`,
353
+ onceByTracking: true
354
+ }));
355
+ switch(outcome.outcome){
356
+ case 'recorded':
357
+ return {
358
+ status: 200,
359
+ body: 'Recorded.'
360
+ };
361
+ case 'already':
362
+ return {
363
+ status: 200,
364
+ body: 'Already recorded.'
365
+ };
366
+ case 'no_such_order':
367
+ return {
368
+ status: 404,
369
+ body: `${PLATFORM_BRAND_NAME} has no order ${label} on this site.`
370
+ };
371
+ case 'blocked':
372
+ return {
373
+ status: 409,
374
+ body: `Order ${label} is ${outcome.from.replace(/_/g, ' ')} in ${PLATFORM_BRAND_NAME} and cannot be shipped.`
375
+ };
376
+ case 'invalid_lines':
377
+ return {
378
+ status: 400,
379
+ body: outcome.message
380
+ };
381
+ }
382
+ }
383
+ /*==========================================
384
+ * THE ROUTE
385
+ *=========================================*/ /** `GET|POST /api/commerce/shipstation/{hostId}` — see the block header. */ export async function shipStationRoute(request, context) {
386
+ var _readClientIp, _ref, _url_searchParams_get;
387
+ const hostId = connectorHostIdOf(context.params);
388
+ if (!hostId) return text(404, 'Not found');
389
+ if (!requestIsSecure(request)) return text(403, `Use the https:// address ${PLATFORM_BRAND_NAME} gave you.`);
390
+ const ip = (_readClientIp = readClientIp(request.headers)) != null ? _readClientIp : 'unknown';
391
+ const rate = await consumeRateLimit(`shipstation:${hostId}:${ip}`, {
392
+ limit: SHIPSTATION_RATE_LIMIT,
393
+ windowMs: 60000
394
+ });
395
+ if (!rate.allowed) {
396
+ return text(429, 'Too many requests; ShipStation will retry.', {
397
+ 'retry-after': String(Math.max(1, Math.ceil((rate.resetMs - Date.now()) / 1000)))
398
+ });
399
+ }
400
+ const firestore = firebaseAdmin.app().firestore();
401
+ const connectionRef = firestore.collection(SHIPSTATION_CONNECTIONS).doc(hostId);
402
+ const stored = await connectionRef.get();
403
+ const connection = stored.exists ? stored.data() : null;
404
+ const keyring = readCommerceSecretKeyring();
405
+ const opened = openShipStationPassword(connection, keyring);
406
+ if (connection && !opened) console.error('shipstation: the stored password could not be opened', hostId);
407
+ const presented = readBasicAuth(request.headers.get('authorization'));
408
+ if (!credentialsMatch(connection ? {
409
+ username: connection.username,
410
+ password: (_ref = opened == null ? void 0 : opened.password) != null ? _ref : null
411
+ } : null, presented)) {
412
+ return unauthorized();
413
+ }
414
+ const proven = connection;
415
+ if ((opened == null ? void 0 : opened.reseal) && keyring) {
416
+ // Sealed under a key the ring has since retired from sealing: seal it
417
+ // again under the current one, so the old key can leave the ring.
418
+ await connectionRef.set(sealShipStationPassword(hostId, opened.password, keyring), {
419
+ merge: true
420
+ }).catch((error)=>console.warn('shipstation: password not resealed', hostId, error));
421
+ }
422
+ const refused = await connectorSiteRefusal(request, hostId);
423
+ if (refused) return refused;
424
+ const url = new URL(request.url);
425
+ const action = String((_url_searchParams_get = url.searchParams.get('action')) != null ? _url_searchParams_get : '').trim().toLowerCase();
426
+ if (action === 'export') {
427
+ if (request.method !== 'GET') return text(405, 'Use GET to export.', {
428
+ allow: 'GET'
429
+ });
430
+ const window = readExportWindow(url.searchParams);
431
+ if ('problem' in window) return text(400, window.problem);
432
+ try {
433
+ const page = await shipStationExport(hostId, window, proven);
434
+ return new Response(page.xml, {
435
+ status: 200,
436
+ headers: {
437
+ 'content-type': 'application/xml; charset=utf-8'
438
+ }
439
+ });
440
+ } catch (error) {
441
+ console.error('shipstation: export failed', hostId, error);
442
+ return text(500, `${PLATFORM_BRAND_NAME} could not read the orders. ShipStation will retry.`);
443
+ }
444
+ }
445
+ if (action === 'shipnotify') {
446
+ var _request_headers_get;
447
+ if (request.method !== 'POST') return text(405, 'Use POST to notify a shipment.', {
448
+ allow: 'POST'
449
+ });
450
+ const declared = Number((_request_headers_get = request.headers.get('content-length')) != null ? _request_headers_get : 0);
451
+ if (declared > SHIPNOTICE_MAX_BYTES) return text(413, 'The notice is too large.');
452
+ const body = await request.text();
453
+ if (Buffer.byteLength(body, 'utf8') > SHIPNOTICE_MAX_BYTES) return text(413, 'The notice is too large.');
454
+ const query = {};
455
+ for (const name of [
456
+ 'order_number',
457
+ 'carrier',
458
+ 'service',
459
+ 'tracking_number'
460
+ ]){
461
+ var _url_searchParams_get1;
462
+ query[name] = (_url_searchParams_get1 = url.searchParams.get(name)) != null ? _url_searchParams_get1 : undefined;
463
+ }
464
+ const notice = CommerceModel.readShipNotice(body, query);
465
+ if ('problem' in notice) return text(400, notice.problem);
466
+ if (!notice.orderNumber && !notice.orderId) return text(400, 'The notice names no order.');
467
+ try {
468
+ const outcome = await recordShipNotice(hostId, notice, digestSecret(body).slice(0, 32));
469
+ await connectionRef.set({
470
+ lastShipNoticeAtMs: Date.now()
471
+ }, {
472
+ merge: true
473
+ }).catch((error)=>console.warn('shipstation: notice time not saved', hostId, error));
474
+ return text(outcome.status, outcome.body);
475
+ } catch (error) {
476
+ console.error('shipstation: shipnotify failed', hostId, error);
477
+ return text(500, `${PLATFORM_BRAND_NAME} could not record the shipment. ShipStation will retry.`);
478
+ }
479
+ }
480
+ return text(400, 'action must be export or shipnotify.');
481
+ }
482
+
483
+ //# sourceMappingURL=shipstation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/shipstation.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 { randomBytes, timingSafeEqual } from 'crypto'\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn/app-utils/platform-brand'\nimport { readClientIp } from '@aglyn/aglyn/app-utils/request-ip'\nimport { needsReseal, openSecret, sealSecret, type SecretBoxKeyring } from '@aglyn/shared-util-tools/secret-box'\nimport { consumeRateLimit, firebaseAdmin } from '@aglyn/tenant-data-admin'\nimport * as CommerceModel from '../model'\nimport { recordOrderShipment } from './fulfill-order'\nimport { readCommerceSecretKeyring } from './order-webhooks'\nimport {\n connectorHostIdOf,\n connectorSiteRefusal,\n connectorText as text,\n digestSecret,\n requestIsSecure,\n} from './shipping-connector-gates'\n\nexport { digestSecret, requestIsSecure } from './shipping-connector-gates'\n\n// lockdown-423: handled — the route asks `lockdownRefusal` itself (through `connectorSiteRefusal`), for the org and site its credentials name, before any read.\n\n/*\n * SHIPSTATION'S CUSTOM STORE ENDPOINT (AGL-3613):\n * `/api/commerce/shipstation/{hostId}`, GET `?action=export` and POST\n * `?action=shipnotify` — the feed and the notice are pure data in\n * `model/shipstation.ts`.\n *\n * ## A machine's route, with every gate of its own\n *\n * ShipStation calls from its own servers with HTTP Basic credentials and\n * names no member, so the route is registered as a MACHINE's\n * (`machine: true`): the dispatcher skips its per-site enablement, release\n * and write-limit gates, and this route answers each of them itself, for\n * the site its URL names, AFTER the credentials are proven — an unproven\n * caller learns nothing about the site, not even whether commerce is on.\n *\n * - HTTPS only, outside development: the credentials ride every request.\n * - A per-site, per-address budget (`SHIPSTATION_RATE_LIMIT`); ShipStation\n * polls from a handful of addresses shared by every store it serves, which\n * is why the dispatcher's address-only bucket was the wrong one.\n * - Credentials minted per site by the console card. The password is sealed\n * with the shared secret box under commerce's keyring\n * (`readCommerceSecretKeyring`), bound to its site by the seal's context,\n * so a site's admin can show it again and a copied document opens for no\n * other site. A request's pair is compared as fixed-length digests in\n * constant time.\n * - The site's commerce must be on, entitled by the plan and released for\n * the org; a security or manual lockdown refuses.\n *\n * ## Which orders, and why a query\n *\n * The feed answers every order MODIFIED in ShipStation's window, whatever\n * its status — a cancel must reach ShipStation or a merchant ships it. Every\n * order writer stamps `updatedAtMs`, every creator stamps `requiresShipping`\n * (`withOrderListFields`), and the feed is ONE indexed query on the pair:\n * `(requiresShipping ==, updatedAtMs range)`. Pages follow a stored cursor,\n * so page 5 does not re-read pages 1 to 4; a page asked out of order falls\n * back to an offset.\n *\n * ## The notice is a shipment, recorded once\n *\n * A ShipNotice becomes a fulfillment through `recordOrderShipment` — the\n * console's own transaction, which also emails the buyer — for the items it\n * names, bounded by what is left to ship. Its tracking number is the\n * parcel's identity: the same number on the same order is answered\n * `already` and writes nothing, however often ShipStation retries or\n * whether the merchant typed it in first.\n */\n\n/** Where each site's credentials are kept: server-only, every client denied. */\nexport const SHIPSTATION_CONNECTIONS = 'commerceShipStationConnections'\n\n/** Requests per minute, per site and per calling address. */\nexport const SHIPSTATION_RATE_LIMIT = 120\n\n/** The largest ShipNotice body read. A notice is a few kilobytes. */\nexport const SHIPNOTICE_MAX_BYTES = 256 * 1024\n\n/** A connection as stored. */\nexport interface ShipStationConnection {\n hostId: string\n username: string\n /** The password, sealed with the secret box; never stored in the clear. */\n sealedPassword: string\n /** The id of the key that sealed it, for rotation. */\n passwordKeyId: string\n createdAtMs: number\n createdBy: string\n rotatedAtMs?: number\n lastExportAtMs?: number\n lastShipNoticeAtMs?: number\n /** Where the last export page ended, so the next page starts after it. */\n exportCursor?: { key: string; page: number; after: [number, string] }\n}\n\n/** A fresh username and password for a site. */\nexport function mintShipStationCredentials(): { username: string; password: string } {\n return {\n username: `aglyn-${randomBytes(6).toString('hex')}`,\n password: randomBytes(24).toString('base64url'),\n }\n}\n\n/** What binds a sealed password to its site: a copy opens for no other. */\nexport const shipStationSealContext = (hostId: string): string => `${SHIPSTATION_CONNECTIONS}/${hostId}#password`\n\n/** The password sealed for a site, with the id of the key that sealed it. */\nexport function sealShipStationPassword(\n hostId: string,\n password: string,\n keyring: SecretBoxKeyring,\n): Pick<ShipStationConnection, 'sealedPassword' | 'passwordKeyId'> {\n return {\n sealedPassword: sealSecret(password, keyring.current, { context: shipStationSealContext(hostId) }),\n passwordKeyId: keyring.current.id,\n }\n}\n\n/**\n * A site's password in the clear, and whether it should be sealed again under\n * the keyring's current key. `null` when it cannot be opened: no keyring, a\n * key the ring no longer holds, or a document copied from another site.\n */\nexport function openShipStationPassword(\n connection: Pick<ShipStationConnection, 'hostId' | 'sealedPassword'> | null,\n keyring: SecretBoxKeyring | null,\n): { password: string; reseal: boolean } | null {\n if (!connection?.sealedPassword || !keyring) return null\n try {\n const opened = openSecret(connection.sealedPassword, keyring, { context: shipStationSealContext(connection.hostId) })\n return { password: opened.plaintext, reseal: needsReseal(opened, keyring) }\n } catch {\n return null\n }\n}\n\n/** The username and password of a Basic `Authorization` header, or `null`. */\nexport function readBasicAuth(header: string | null | undefined): { username: string; password: string } | null {\n const value = String(header ?? '')\n const match = /^Basic\\s+([A-Za-z0-9+/=_-]+)\\s*$/i.exec(value)\n if (!match) return null\n let decoded: string\n try {\n decoded = Buffer.from(match[1], 'base64').toString('utf8')\n } catch {\n return null\n }\n const colon = decoded.indexOf(':')\n if (colon < 0) return null\n return { username: decoded.slice(0, colon), password: decoded.slice(colon + 1) }\n}\n\n/**\n * Whether the presented credentials are the stored ones. Both halves are\n * compared, always, as fixed-length digests, so neither a wrong username nor\n * a wrong password answers faster than the other. A password that could not\n * be opened (`null`) matches nothing.\n */\nexport function credentialsMatch(\n stored: { username: string; password: string | null } | null,\n presented: { username: string; password: string } | null,\n): boolean {\n const expectedUser = Buffer.from(digestSecret(stored?.username ?? '\\u0000'), 'hex')\n const expectedPass = Buffer.from(digestSecret(stored?.password ?? '\\u0000'), 'hex')\n const user = Buffer.from(digestSecret(presented?.username ?? ''), 'hex')\n const pass = Buffer.from(digestSecret(presented?.password ?? ''), 'hex')\n const userOk = timingSafeEqual(user, expectedUser)\n const passOk = timingSafeEqual(pass, expectedPass)\n return Boolean(stored && stored.password !== null && presented && userOk && passOk)\n}\n\nconst unauthorized = (): Response =>\n text(401, `The ShipStation username or password is wrong. Copy them again from ${PLATFORM_BRAND_NAME}.`, {\n 'www-authenticate': `Basic realm=\"${PLATFORM_BRAND_NAME.replace(/\"/g, '')} ShipStation\", charset=\"UTF-8\"`,\n })\n\n/*==========================================\n * EXPORT\n *=========================================*/\n\ntype Snapshot = FirebaseFirestore.QueryDocumentSnapshot\n\n/**\n * What the feed needs of each product a page names: every variant's weight,\n * image and option choices, one `getAll` per page.\n */\nexport async function shipStationProductsFor(\n hostRef: FirebaseFirestore.DocumentReference,\n orders: ReadonlyArray<Partial<CommerceModel.HostOrder>>,\n): Promise<CommerceModel.ShipStationProducts> {\n const ids = [\n ...new Set(\n orders.flatMap((order) => (order.lineItems ?? []).map((line) => line?.productId)).filter((id): id is string => Boolean(id)),\n ),\n ].filter((id) => !id.includes('/'))\n const products: Record<string, Record<string, CommerceModel.ShipStationProductFacts>> = {}\n const collection = hostRef.collection('products')\n for (let at = 0; at < ids.length; at += 100) {\n const docs = await hostRef.firestore.getAll(...ids.slice(at, at + 100).map((id) => collection.doc(id)))\n for (const doc of docs) {\n if (!doc.exists) continue\n const product = CommerceModel.liftLegacyProduct(doc.data() as never)\n const image = (product.mediaUrls ?? [])[0] ?? (doc.get('imageUrl') as string | undefined)\n const variants: Record<string, CommerceModel.ShipStationProductFacts> = {}\n const first = product.variants[0]\n variants[''] = {\n ...(first?.weightGrams ? { grams: first.weightGrams } : {}),\n ...(image ? { imageUrl: image } : {}),\n }\n for (const variant of product.variants) {\n variants[variant.id] = {\n ...(variant.weightGrams ? { grams: variant.weightGrams } : {}),\n ...(variant.imageUrl || image ? { imageUrl: variant.imageUrl || image } : {}),\n ...(variant.options && Object.keys(variant.options).length ? { options: variant.options } : {}),\n }\n }\n products[doc.id] = variants\n }\n }\n return products\n}\n\n/** The window ShipStation asked for, or the sentence explaining why it cannot be read. */\nexport function readExportWindow(\n query: URLSearchParams,\n): { startMs: number; endMs: number; page: number } | { problem: string } {\n const startMs = CommerceModel.parseShipStationDate(query.get('start_date'))\n const endMs = CommerceModel.parseShipStationDate(query.get('end_date'))\n if (startMs === null || endMs === null) {\n return { problem: 'start_date and end_date must be dates as MM/dd/yyyy HH:mm, in UTC.' }\n }\n if (endMs < startMs) return { problem: 'end_date is before start_date.' }\n if (endMs - startMs > CommerceModel.SHIPSTATION_MAX_WINDOW_MS) {\n return { problem: 'Ask for at most a year of orders at a time.' }\n }\n const pageText = query.get('page') ?? '1'\n const page = /^\\d{1,5}$/.test(pageText) ? Number(pageText) : NaN\n if (!Number.isInteger(page) || page < 1) return { problem: 'page must be a whole number from 1.' }\n // A window's end is a minute, so the whole of its last minute is inside it.\n return { startMs, endMs: endMs + 59_999, page }\n}\n\n/** One page of the feed, for a site whose request is already proven. */\nexport async function shipStationExport(\n hostId: string,\n window: { startMs: number; endMs: number; page: number },\n connection: ShipStationConnection,\n options: { pageSize?: number } = {},\n): Promise<{ xml: string; pages: number; orders: number }> {\n const firestore = firebaseAdmin.app().firestore()\n const hostRef = firestore.collection('hosts').doc(hostId)\n const connectionRef = firestore.collection(SHIPSTATION_CONNECTIONS).doc(hostId)\n const pageSize = options.pageSize ?? CommerceModel.SHIPSTATION_PAGE_SIZE\n const idPath = firebaseAdmin.firestore.FieldPath.documentId()\n const base = hostRef\n .collection('orders')\n .where('requiresShipping', '==', true)\n .where('updatedAtMs', '>=', window.startMs)\n .where('updatedAtMs', '<=', window.endMs)\n const total = Number((await base.count().get()).data().count) || 0\n const pages = Math.max(1, Math.ceil(total / pageSize))\n const ordered = base.orderBy('updatedAtMs', 'asc').orderBy(idPath, 'asc')\n const key = `${window.startMs}|${window.endMs}`\n const cursor = connection.exportCursor\n const followsCursor = window.page > 1 && cursor?.key === key && cursor.page === window.page - 1\n const query = window.page === 1\n ? ordered\n : followsCursor\n ? ordered.startAfter(...(cursor?.after ?? []))\n : ordered.offset((window.page - 1) * pageSize)\n const snapshot = window.page > pages ? null : await query.limit(pageSize).get()\n const docs: Snapshot[] = snapshot?.docs ?? []\n const sources = docs\n .map((doc) => ({ docId: doc.id, order: (doc.data() ?? {}) as CommerceModel.ShipStationOrderSource['order'] }))\n .filter((entry) => CommerceModel.shipStationCanImport(entry.order))\n const products = await shipStationProductsFor(hostRef, sources.map((entry) => entry.order))\n const xml = CommerceModel.shipStationOrdersXml(\n sources.map((entry) => CommerceModel.shipStationOrderXml(entry, products)),\n pages,\n )\n const last = docs[docs.length - 1]\n await connectionRef\n .set(\n {\n lastExportAtMs: Date.now(),\n ...(last\n ? { exportCursor: { key, page: window.page, after: [Number(last.get('updatedAtMs') ?? 0), last.id] } }\n : {}),\n },\n { merge: true },\n )\n .catch((error: unknown) => console.warn('shipstation: cursor not saved', hostId, error))\n return { xml, pages, orders: sources.length }\n}\n\n/*==========================================\n * SHIPNOTIFY\n *=========================================*/\n\n/** The order a notice names, found by its id first and its number second. */\nasync function findNoticeOrder(\n hostRef: FirebaseFirestore.DocumentReference,\n notice: CommerceModel.ShipNotice,\n): Promise<FirebaseFirestore.DocumentSnapshot | null> {\n const orders = hostRef.collection('orders')\n const byId = CommerceModel.parseShippingOrderRef(notice.orderId)\n if (byId?.id && !byId.id.includes('/')) {\n const doc = await orders.doc(byId.id).get()\n if (doc.exists) return doc\n }\n const ref = CommerceModel.parseShippingOrderRef(notice.orderNumber)\n if (!ref) return null\n if (ref.number !== undefined) {\n const matches = await orders.where('number', '==', ref.number).limit(2).get()\n // Two orders under one number is a store this route cannot decide for.\n if (matches.size === 1) return matches.docs[0]\n if (matches.size > 1) return null\n }\n if (ref.id && !ref.id.includes('/')) {\n const doc = await orders.doc(ref.id).get()\n if (doc.exists) return doc\n }\n return null\n}\n\n/** What a notice came to, for the route to answer ShipStation with. */\nexport type ShipNoticeOutcome =\n | { status: 200; body: string }\n | { status: 400 | 404 | 409; body: string }\n\n/** The shipping app a notice came from: the prefix of the parcel's idempotency key. */\nexport type ShipNoticeSource = 'shipstation' | 'shippingeasy'\n\n/**\n * Records one ShipNotice as a fulfillment, once. Every connector that hands\n * shipments back reads its own wire format into a `ShipNotice` and records\n * it here, so the parcel-once rule, the bound by what is left and the\n * shipped email are one implementation (AGL-3613, AGL-3633).\n */\nexport async function recordShipNotice(\n hostId: string,\n notice: CommerceModel.ShipNotice,\n bodyDigest: string,\n options: { source?: ShipNoticeSource } = {},\n): Promise<ShipNoticeOutcome> {\n const source = options.source ?? 'shipstation'\n const hostRef = firebaseAdmin.app().firestore().collection('hosts').doc(hostId)\n const doc = await findNoticeOrder(hostRef, notice)\n const label = notice.orderNumber ?? notice.orderId ?? '?'\n if (!doc) return { status: 404, body: `${PLATFORM_BRAND_NAME} has no order ${label} on this site.` }\n const order = CommerceModel.liftLegacyOrder((doc.data() ?? {}) as never)\n const carrier = CommerceModel.shipStationCarrierName(notice.carrier)\n const trackingNumber = notice.trackingNumber\n\n if (trackingNumber && CommerceModel.fulfillmentWithTracking(order, trackingNumber)) {\n return { status: 200, body: 'Already recorded.' }\n }\n const named = CommerceModel.shipNoticeLines(order, notice.items)\n let lineItems: Array<{ lineItemId: number; quantity: number }> | undefined\n if (named.lines) {\n if (!named.lines.length) {\n return { status: 400, body: `None of the shipped items is on order ${label}: ${named.unknown.join(', ')}.` }\n }\n // Bounded by what is left: ShipStation's copy of the order may predate a\n // parcel the merchant shipped from Aglyn, and asking for more than\n // remains would refuse the whole notice.\n const remaining = new Map(\n CommerceModel.orderLineFulfillmentStates(order).map((state) => [state.lineItemId, state.remainingQuantity]),\n )\n const merged = new Map<number, number>()\n for (const entry of named.lines) merged.set(entry.lineItemId, (merged.get(entry.lineItemId) ?? 0) + entry.quantity)\n lineItems = [...merged.entries()]\n .map(([lineItemId, quantity]) => ({ lineItemId, quantity: Math.min(quantity, remaining.get(lineItemId) ?? 0) }))\n .filter((entry) => entry.quantity > 0)\n if (!lineItems.length) return { status: 200, body: 'Nothing on this notice is left to ship; nothing recorded.' }\n }\n\n const outcome = await recordOrderShipment({\n hostId,\n orderId: doc.id,\n to: 'fulfilled',\n carrier,\n trackingNumber,\n ...(lineItems ? { lineItems } : {}),\n // The parcel's identity: its tracking number, or — for a \"mark as\n // shipped\" with none — the notice itself, so a redelivery is one parcel.\n idempotencyKey: trackingNumber\n ? `${source}:${CommerceModel.normalizeTrackingNumber(trackingNumber)}`\n : `${source}-notice:${bodyDigest}`,\n onceByTracking: true,\n })\n switch (outcome.outcome) {\n case 'recorded':\n return { status: 200, body: 'Recorded.' }\n case 'already':\n return { status: 200, body: 'Already recorded.' }\n case 'no_such_order':\n return { status: 404, body: `${PLATFORM_BRAND_NAME} has no order ${label} on this site.` }\n case 'blocked':\n return { status: 409, body: `Order ${label} is ${outcome.from.replace(/_/g, ' ')} in ${PLATFORM_BRAND_NAME} and cannot be shipped.` }\n case 'invalid_lines':\n return { status: 400, body: outcome.message }\n }\n}\n\n/*==========================================\n * THE ROUTE\n *=========================================*/\n\n/** `GET|POST /api/commerce/shipstation/{hostId}` — see the block header. */\nexport async function shipStationRoute(\n request: Request,\n context: { params: Record<string, string | string[]> },\n): Promise<Response> {\n const hostId = connectorHostIdOf(context.params)\n if (!hostId) return text(404, 'Not found')\n if (!requestIsSecure(request)) return text(403, `Use the https:// address ${PLATFORM_BRAND_NAME} gave you.`)\n\n const ip = readClientIp(request.headers) ?? 'unknown'\n const rate = await consumeRateLimit(`shipstation:${hostId}:${ip}`, {\n limit: SHIPSTATION_RATE_LIMIT,\n windowMs: 60_000,\n })\n if (!rate.allowed) {\n return text(429, 'Too many requests; ShipStation will retry.', {\n 'retry-after': String(Math.max(1, Math.ceil((rate.resetMs - Date.now()) / 1000))),\n })\n }\n\n const firestore = firebaseAdmin.app().firestore()\n const connectionRef = firestore.collection(SHIPSTATION_CONNECTIONS).doc(hostId)\n const stored = await connectionRef.get()\n const connection = stored.exists ? (stored.data() as ShipStationConnection) : null\n const keyring = readCommerceSecretKeyring()\n const opened = openShipStationPassword(connection, keyring)\n if (connection && !opened) console.error('shipstation: the stored password could not be opened', hostId)\n const presented = readBasicAuth(request.headers.get('authorization'))\n if (!credentialsMatch(connection ? { username: connection.username, password: opened?.password ?? null } : null, presented)) {\n return unauthorized()\n }\n const proven = connection as ShipStationConnection\n if (opened?.reseal && keyring) {\n // Sealed under a key the ring has since retired from sealing: seal it\n // again under the current one, so the old key can leave the ring.\n await connectionRef\n .set(sealShipStationPassword(hostId, opened.password, keyring), { merge: true })\n .catch((error: unknown) => console.warn('shipstation: password not resealed', hostId, error))\n }\n\n const refused = await connectorSiteRefusal(request, hostId)\n if (refused) return refused\n\n const url = new URL(request.url)\n const action = String(url.searchParams.get('action') ?? '').trim().toLowerCase()\n if (action === 'export') {\n if (request.method !== 'GET') return text(405, 'Use GET to export.', { allow: 'GET' })\n const window = readExportWindow(url.searchParams)\n if ('problem' in window) return text(400, window.problem)\n try {\n const page = await shipStationExport(hostId, window, proven)\n return new Response(page.xml, { status: 200, headers: { 'content-type': 'application/xml; charset=utf-8' } })\n } catch (error) {\n console.error('shipstation: export failed', hostId, error)\n return text(500, `${PLATFORM_BRAND_NAME} could not read the orders. ShipStation will retry.`)\n }\n }\n if (action === 'shipnotify') {\n if (request.method !== 'POST') return text(405, 'Use POST to notify a shipment.', { allow: 'POST' })\n const declared = Number(request.headers.get('content-length') ?? 0)\n if (declared > SHIPNOTICE_MAX_BYTES) return text(413, 'The notice is too large.')\n const body = await request.text()\n if (Buffer.byteLength(body, 'utf8') > SHIPNOTICE_MAX_BYTES) return text(413, 'The notice is too large.')\n const query: Record<string, string | undefined> = {}\n for (const name of ['order_number', 'carrier', 'service', 'tracking_number']) {\n query[name] = url.searchParams.get(name) ?? undefined\n }\n const notice = CommerceModel.readShipNotice(body, query)\n if ('problem' in notice) return text(400, notice.problem)\n if (!notice.orderNumber && !notice.orderId) return text(400, 'The notice names no order.')\n try {\n const outcome = await recordShipNotice(hostId, notice, digestSecret(body).slice(0, 32))\n await connectionRef\n .set({ lastShipNoticeAtMs: Date.now() }, { merge: true })\n .catch((error: unknown) => console.warn('shipstation: notice time not saved', hostId, error))\n return text(outcome.status, outcome.body)\n } catch (error) {\n console.error('shipstation: shipnotify failed', hostId, error)\n return text(500, `${PLATFORM_BRAND_NAME} could not record the shipment. ShipStation will retry.`)\n }\n }\n return text(400, 'action must be export or shipnotify.')\n}\n"],"names":["randomBytes","timingSafeEqual","PLATFORM_BRAND_NAME","readClientIp","needsReseal","openSecret","sealSecret","consumeRateLimit","firebaseAdmin","CommerceModel","recordOrderShipment","readCommerceSecretKeyring","connectorHostIdOf","connectorSiteRefusal","connectorText","text","digestSecret","requestIsSecure","SHIPSTATION_CONNECTIONS","SHIPSTATION_RATE_LIMIT","SHIPNOTICE_MAX_BYTES","mintShipStationCredentials","username","toString","password","shipStationSealContext","hostId","sealShipStationPassword","keyring","sealedPassword","current","context","passwordKeyId","id","openShipStationPassword","connection","opened","plaintext","reseal","readBasicAuth","header","value","String","match","exec","decoded","Buffer","from","colon","indexOf","slice","credentialsMatch","stored","presented","expectedUser","expectedPass","user","pass","userOk","passOk","Boolean","unauthorized","replace","shipStationProductsFor","hostRef","orders","ids","Set","flatMap","order","lineItems","map","line","productId","filter","includes","products","collection","at","length","docs","firestore","getAll","doc","product","exists","liftLegacyProduct","data","image","mediaUrls","get","variants","first","weightGrams","grams","imageUrl","variant","options","Object","keys","readExportWindow","query","startMs","parseShipStationDate","endMs","problem","SHIPSTATION_MAX_WINDOW_MS","pageText","page","test","Number","NaN","isInteger","shipStationExport","window","last","app","connectionRef","pageSize","SHIPSTATION_PAGE_SIZE","idPath","FieldPath","documentId","base","where","total","count","pages","Math","max","ceil","ordered","orderBy","key","cursor","exportCursor","followsCursor","startAfter","after","offset","snapshot","limit","sources","docId","entry","shipStationCanImport","xml","shipStationOrdersXml","shipStationOrderXml","set","lastExportAtMs","Date","now","merge","catch","error","console","warn","findNoticeOrder","notice","byId","parseShippingOrderRef","orderId","ref","orderNumber","number","undefined","matches","size","recordShipNotice","bodyDigest","source","label","status","body","liftLegacyOrder","carrier","shipStationCarrierName","trackingNumber","fulfillmentWithTracking","named","shipNoticeLines","items","lines","merged","unknown","join","remaining","Map","orderLineFulfillmentStates","state","lineItemId","remainingQuantity","quantity","entries","min","outcome","to","idempotencyKey","normalizeTrackingNumber","onceByTracking","message","shipStationRoute","request","url","params","ip","headers","rate","windowMs","allowed","resetMs","proven","refused","URL","action","searchParams","trim","toLowerCase","method","allow","Response","declared","byteLength","name","readShipNotice","lastShipNoticeAtMs"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,EAAEC,eAAe,QAAQ,SAAQ;AACrD,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,WAAW,EAAEC,UAAU,EAAEC,UAAU,QAA+B,sCAAqC;AAChH,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,2BAA0B;AAC1E,YAAYC,mBAAmB,oBAAU;AACzC,SAASC,mBAAmB,QAAQ,qBAAiB;AACrD,SAASC,yBAAyB,QAAQ,sBAAkB;AAC5D,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,iBAAiBC,IAAI,EACrBC,YAAY,EACZC,eAAe,QACV,gCAA4B;AAEn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AAOL,KAAK,KAAK;QACtD,MAAM+J,OAAO,MAAM6B,QAAQ5L,IAAI;QAC/B,IAAI+B,OAAOiL,UAAU,CAACjD,MAAM,UAAU1J,sBAAsB,OAAOL,KAAK,KAAK;QAC7E,MAAMsF,QAA4C,CAAC;QACnD,KAAK,MAAM2H,QAAQ;YAAC;YAAgB;YAAW;YAAW;SAAkB,CAAE;gBAC9DpB;YAAdvG,KAAK,CAAC2H,KAAK,IAAGpB,yBAAAA,IAAIY,YAAY,CAAC9H,GAAG,CAACsI,iBAArBpB,yBAA8BtC;QAC9C;QACA,MAAMP,SAAStJ,cAAcwN,cAAc,CAACnD,MAAMzE;QAClD,IAAI,aAAa0D,QAAQ,OAAOhJ,KAAK,KAAKgJ,OAAOtD,OAAO;QACxD,IAAI,CAACsD,OAAOK,WAAW,IAAI,CAACL,OAAOG,OAAO,EAAE,OAAOnJ,KAAK,KAAK;QAC7D,IAAI;YACF,MAAMqL,UAAU,MAAM3B,iBAAiB/I,QAAQqI,QAAQ/I,aAAa8J,MAAM5H,KAAK,CAAC,GAAG;YACnF,MAAMmE,cACHgC,GAAG,CAAC;gBAAE6E,oBAAoB3E,KAAKC,GAAG;YAAG,GAAG;gBAAEC,OAAO;YAAK,GACtDC,KAAK,CAAC,CAACC,QAAmBC,QAAQC,IAAI,CAAC,sCAAsCnI,QAAQiI;YACxF,OAAO5I,KAAKqL,QAAQvB,MAAM,EAAEuB,QAAQtB,IAAI;QAC1C,EAAE,OAAOnB,OAAO;YACdC,QAAQD,KAAK,CAAC,kCAAkCjI,QAAQiI;YACxD,OAAO5I,KAAK,KAAK,GAAGb,oBAAoB,uDAAuD,CAAC;QAClG;IACF;IACA,OAAOa,KAAK,KAAK;AACnB"}
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import type { SitePageResolver } from '@aglyn/aglyn/server';
18
+ import * as Aglyn from '@aglyn/aglyn/server';
18
19
  /**
19
20
  * Commerce page resolver (AGL-292/298/418), relocated verbatim from the
20
21
  * tenant loader: /products/{slug} renders the host's designated PDP
@@ -24,3 +25,7 @@ import type { SitePageResolver } from '@aglyn/aglyn/server';
24
25
  * undefined for everything else so the loader falls through.
25
26
  */
26
27
  export declare const commerceSitePageResolver: SitePageResolver;
28
+ /** The order-status page's node tree, root first, for the layout's slot. */
29
+ export declare function buildOrderStatusNodes(): Record<string, Aglyn.AglynNodeSchema>;
30
+ /** The return form's node tree, root first, for the layout's slot. */
31
+ export declare function buildReturnRequestNodes(): Record<string, Aglyn.AglynNodeSchema>;