@aglyn/plugins-commerce 1.0.0-beta.285 → 1.0.0-beta.288

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 (430) hide show
  1. package/README.md +1 -1
  2. package/package.json +13 -13
  3. package/src/lib/components/cart.js +25 -12
  4. package/src/lib/components/cart.js.map +1 -1
  5. package/src/lib/components/commerce-console-page.js +70 -13
  6. package/src/lib/components/commerce-console-page.js.map +1 -1
  7. package/src/lib/components/console/order-detail-dialog.component.js +2 -1
  8. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
  9. package/src/lib/components/console/order-webhooks-card.component.js +1 -1
  10. package/src/lib/components/console/order-webhooks-card.component.js.map +1 -1
  11. package/src/lib/components/console/payment-methods-card.component.js +1 -1
  12. package/src/lib/components/console/payment-methods-card.component.js.map +1 -1
  13. package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +5 -0
  14. package/src/lib/components/console/pos/pos-cart-panel.component.js +18 -12
  15. package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -1
  16. package/src/lib/components/console/pos/pos-hardware-api.d.ts +76 -5
  17. package/src/lib/components/console/pos/pos-hardware-api.js +53 -11
  18. package/src/lib/components/console/pos/pos-hardware-api.js.map +1 -1
  19. package/src/lib/components/console/pos/pos-hardware-buyer.component.d.ts +18 -0
  20. package/src/lib/components/console/pos/pos-hardware-buyer.component.js +629 -0
  21. package/src/lib/components/console/pos/pos-hardware-buyer.component.js.map +1 -0
  22. package/src/lib/components/console/pos/pos-hardware-sale-api.d.ts +162 -0
  23. package/src/lib/components/console/pos/pos-hardware-sale-api.js +122 -0
  24. package/src/lib/components/console/pos/pos-hardware-sale-api.js.map +1 -0
  25. package/src/lib/components/console/pos/pos-hardware-sale-terms.component.d.ts +39 -0
  26. package/src/lib/components/console/pos/pos-hardware-sale-terms.component.js +251 -0
  27. package/src/lib/components/console/pos/pos-hardware-sale-terms.component.js.map +1 -0
  28. package/src/lib/components/console/pos/use-pos-display.js +50 -0
  29. package/src/lib/components/console/pos/use-pos-display.js.map +1 -1
  30. package/src/lib/components/console/pos-cellular-control.component.d.ts +41 -0
  31. package/src/lib/components/console/pos-cellular-control.component.js +211 -0
  32. package/src/lib/components/console/pos-cellular-control.component.js.map +1 -0
  33. package/src/lib/components/console/pos-devices-card.component.d.ts +9 -1
  34. package/src/lib/components/console/pos-devices-card.component.js +47 -15
  35. package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
  36. package/src/lib/components/console/pos-display/pos-display-api.d.ts +6 -0
  37. package/src/lib/components/console/pos-display/pos-display-api.js +8 -1
  38. package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -1
  39. package/src/lib/components/console/pos-display-page.component.d.ts +13 -0
  40. package/src/lib/components/console/pos-display-page.component.js +44 -2
  41. package/src/lib/components/console/pos-display-page.component.js.map +1 -1
  42. package/src/lib/components/console/pos-hardware-card.component.d.ts +12 -4
  43. package/src/lib/components/console/pos-hardware-card.component.js +157 -36
  44. package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
  45. package/src/lib/components/console/pos-hardware-orders-staff-page.component.js +360 -80
  46. package/src/lib/components/console/pos-hardware-orders-staff-page.component.js.map +1 -1
  47. package/src/lib/components/console/pos-hardware-terms-page.component.d.ts +34 -0
  48. package/src/lib/components/console/pos-hardware-terms-page.component.js +257 -0
  49. package/src/lib/components/console/pos-hardware-terms-page.component.js.map +1 -0
  50. package/src/lib/components/console/pos-hardware-terms-sign-page.component.d.ts +27 -0
  51. package/src/lib/components/console/pos-hardware-terms-sign-page.component.js +104 -0
  52. package/src/lib/components/console/pos-hardware-terms-sign-page.component.js.map +1 -0
  53. package/src/lib/components/console/pos-hardware-waiting-card.component.d.ts +24 -0
  54. package/src/lib/components/console/pos-hardware-waiting-card.component.js +205 -0
  55. package/src/lib/components/console/pos-hardware-waiting-card.component.js.map +1 -0
  56. package/src/lib/components/console/pos-ops/pos-check-in-dialog.component.js +297 -201
  57. package/src/lib/components/console/pos-ops/pos-check-in-dialog.component.js.map +1 -1
  58. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.d.ts +3 -0
  59. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js +260 -92
  60. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js.map +1 -1
  61. package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +9 -0
  62. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +15 -6
  63. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -1
  64. package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.d.ts +25 -0
  65. package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.js +136 -0
  66. package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.js.map +1 -0
  67. package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +6 -0
  68. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +48 -31
  69. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -1
  70. package/src/lib/components/console/pos-page.component.d.ts +1 -1
  71. package/src/lib/components/console/pos-page.component.js +63 -12
  72. package/src/lib/components/console/pos-page.component.js.map +1 -1
  73. package/src/lib/components/console/pos-reader-splash-setting.component.js +1 -1
  74. package/src/lib/components/console/pos-reader-splash-setting.component.js.map +1 -1
  75. package/src/lib/components/console/product-check-in-fields.component.d.ts +4 -2
  76. package/src/lib/components/console/product-check-in-fields.component.js +60 -14
  77. package/src/lib/components/console/product-check-in-fields.component.js.map +1 -1
  78. package/src/lib/components/console/product-editor-dialog.component.js +44 -1
  79. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  80. package/src/lib/components/console/product-hardware-sku-field.component.d.ts +19 -0
  81. package/src/lib/components/console/product-hardware-sku-field.component.js +92 -0
  82. package/src/lib/components/console/product-hardware-sku-field.component.js.map +1 -0
  83. package/src/lib/components/console/product-kiosk-offer-field.component.d.ts +22 -0
  84. package/src/lib/components/console/product-kiosk-offer-field.component.js +94 -0
  85. package/src/lib/components/console/product-kiosk-offer-field.component.js.map +1 -0
  86. package/src/lib/components/console/product-register-fields.component.d.ts +4 -0
  87. package/src/lib/components/console/product-register-fields.component.js +31 -2
  88. package/src/lib/components/console/product-register-fields.component.js.map +1 -1
  89. package/src/lib/components/console/products-hub-card.component.js +11 -2
  90. package/src/lib/components/console/products-hub-card.component.js.map +1 -1
  91. package/src/lib/components/console/register-hardware-card.component.d.ts +11 -0
  92. package/src/lib/components/console/register-hardware-card.component.js +56 -27
  93. package/src/lib/components/console/register-hardware-card.component.js.map +1 -1
  94. package/src/lib/components/console/reservation-guests-dialog.component.d.ts +28 -0
  95. package/src/lib/components/console/reservation-guests-dialog.component.js +189 -0
  96. package/src/lib/components/console/reservation-guests-dialog.component.js.map +1 -0
  97. package/src/lib/components/console/reservations-card.component.d.ts +9 -0
  98. package/src/lib/components/console/reservations-card.component.js +158 -23
  99. package/src/lib/components/console/reservations-card.component.js.map +1 -1
  100. package/src/lib/components/console/shippingeasy-card.component.js +1 -1
  101. package/src/lib/components/console/shippingeasy-card.component.js.map +1 -1
  102. package/src/lib/components/console/shipstation-card.component.d.ts +1 -1
  103. package/src/lib/components/console/shipstation-card.component.js +3 -3
  104. package/src/lib/components/console/shipstation-card.component.js.map +1 -1
  105. package/src/lib/components/product-detail.d.ts +4 -0
  106. package/src/lib/components/product-detail.js +40 -5
  107. package/src/lib/components/product-detail.js.map +1 -1
  108. package/src/lib/components/product-reviews.js +28 -11
  109. package/src/lib/components/product-reviews.js.map +1 -1
  110. package/src/lib/components/reservation-widget.js +28 -5
  111. package/src/lib/components/reservation-widget.js.map +1 -1
  112. package/src/lib/components/use-day-picker.d.ts +25 -0
  113. package/src/lib/components/use-day-picker.js +57 -0
  114. package/src/lib/components/use-day-picker.js.map +1 -0
  115. package/src/lib/constants/operator-alerts.d.ts +55 -0
  116. package/src/lib/constants/operator-alerts.js +156 -1
  117. package/src/lib/constants/operator-alerts.js.map +1 -1
  118. package/src/lib/declarations.console-server.js +54 -1
  119. package/src/lib/declarations.console-server.js.map +1 -1
  120. package/src/lib/declarations.d.ts +4 -2
  121. package/src/lib/declarations.js +15 -4
  122. package/src/lib/declarations.js.map +1 -1
  123. package/src/lib/declarations.server.js +9 -0
  124. package/src/lib/declarations.server.js.map +1 -1
  125. package/src/lib/model/commerce-cart.d.ts +9 -1
  126. package/src/lib/model/commerce-cart.js +4 -3
  127. package/src/lib/model/commerce-cart.js.map +1 -1
  128. package/src/lib/model/commerce-check-in-product.d.ts +26 -0
  129. package/src/lib/model/commerce-check-in-product.js +64 -2
  130. package/src/lib/model/commerce-check-in-product.js.map +1 -1
  131. package/src/lib/model/commerce-check-in-record.d.ts +127 -0
  132. package/src/lib/model/commerce-check-in-record.js +36 -0
  133. package/src/lib/model/commerce-check-in-record.js.map +1 -0
  134. package/src/lib/model/commerce-check-in.d.ts +91 -87
  135. package/src/lib/model/commerce-check-in.js +186 -62
  136. package/src/lib/model/commerce-check-in.js.map +1 -1
  137. package/src/lib/model/commerce-kiosk-offer.d.ts +31 -0
  138. package/src/lib/model/commerce-kiosk-offer.js +35 -0
  139. package/src/lib/model/commerce-kiosk-offer.js.map +1 -0
  140. package/src/lib/model/commerce-orders.d.ts +76 -0
  141. package/src/lib/model/commerce-orders.js +6 -0
  142. package/src/lib/model/commerce-orders.js.map +1 -1
  143. package/src/lib/model/commerce-pos-day-report.d.ts +54 -1
  144. package/src/lib/model/commerce-pos-day-report.js +39 -2
  145. package/src/lib/model/commerce-pos-day-report.js.map +1 -1
  146. package/src/lib/model/commerce-pos-offline.d.ts +1 -1
  147. package/src/lib/model/commerce-pos-offline.js +6 -1
  148. package/src/lib/model/commerce-pos-offline.js.map +1 -1
  149. package/src/lib/model/commerce-pos-ops.js +3 -2
  150. package/src/lib/model/commerce-pos-ops.js.map +1 -1
  151. package/src/lib/model/commerce-pos.d.ts +36 -3
  152. package/src/lib/model/commerce-pos.js +14 -6
  153. package/src/lib/model/commerce-pos.js.map +1 -1
  154. package/src/lib/model/commerce-receipt.js +3 -2
  155. package/src/lib/model/commerce-receipt.js.map +1 -1
  156. package/src/lib/model/commerce-reservations.d.ts +69 -4
  157. package/src/lib/model/commerce-reservations.js +57 -5
  158. package/src/lib/model/commerce-reservations.js.map +1 -1
  159. package/src/lib/model/commerce.d.ts +66 -0
  160. package/src/lib/model/commerce.js +15 -0
  161. package/src/lib/model/commerce.js.map +1 -1
  162. package/src/lib/model/order-list-fields.d.ts +11 -0
  163. package/src/lib/model/order-list-fields.js +17 -1
  164. package/src/lib/model/order-list-fields.js.map +1 -1
  165. package/src/lib/model/own-store-tax-summary.d.ts +152 -0
  166. package/src/lib/model/own-store-tax-summary.js +288 -0
  167. package/src/lib/model/own-store-tax-summary.js.map +1 -0
  168. package/src/lib/model/plugin-permissions.d.ts +74 -0
  169. package/src/lib/model/plugin-permissions.js +224 -7
  170. package/src/lib/model/plugin-permissions.js.map +1 -1
  171. package/src/lib/model/pos-cellular.d.ts +223 -0
  172. package/src/lib/model/pos-cellular.js +293 -0
  173. package/src/lib/model/pos-cellular.js.map +1 -0
  174. package/src/lib/model/pos-hardware-in-person.d.ts +98 -0
  175. package/src/lib/model/pos-hardware-in-person.js +224 -0
  176. package/src/lib/model/pos-hardware-in-person.js.map +1 -0
  177. package/src/lib/model/pos-hardware-tax-summary.d.ts +166 -0
  178. package/src/lib/model/pos-hardware-tax-summary.js +225 -0
  179. package/src/lib/model/pos-hardware-tax-summary.js.map +1 -0
  180. package/src/lib/model/pos-hardware-terms.d.ts +74 -0
  181. package/src/lib/model/pos-hardware-terms.js +115 -0
  182. package/src/lib/model/pos-hardware-terms.js.map +1 -0
  183. package/src/lib/model/pos-hardware.d.ts +349 -7
  184. package/src/lib/model/pos-hardware.js +291 -20
  185. package/src/lib/model/pos-hardware.js.map +1 -1
  186. package/src/lib/model/product-write.d.ts +10 -0
  187. package/src/lib/model/product-write.js +4 -2
  188. package/src/lib/model/product-write.js.map +1 -1
  189. package/src/lib/model/workspace-site-permissions.d.ts +26 -0
  190. package/src/lib/model/workspace-site-permissions.js +81 -0
  191. package/src/lib/model/workspace-site-permissions.js.map +1 -0
  192. package/src/lib/plugin.js +16 -0
  193. package/src/lib/plugin.js.map +1 -1
  194. package/src/lib/server/billing-webhook.js +25 -1
  195. package/src/lib/server/billing-webhook.js.map +1 -1
  196. package/src/lib/server/cancel-order.js +7 -5
  197. package/src/lib/server/cancel-order.js.map +1 -1
  198. package/src/lib/server/cart-checkout.js +20 -8
  199. package/src/lib/server/cart-checkout.js.map +1 -1
  200. package/src/lib/server/cart.js +29 -0
  201. package/src/lib/server/cart.js.map +1 -1
  202. package/src/lib/server/checkout.js +42 -13
  203. package/src/lib/server/checkout.js.map +1 -1
  204. package/src/lib/server/collection-membership.d.ts +4 -0
  205. package/src/lib/server/collection-membership.js +5 -10
  206. package/src/lib/server/collection-membership.js.map +1 -1
  207. package/src/lib/server/commerce-site-keys.d.ts +48 -0
  208. package/src/lib/server/commerce-site-keys.js +61 -0
  209. package/src/lib/server/commerce-site-keys.js.map +1 -0
  210. package/src/lib/server/draft-order.js +8 -5
  211. package/src/lib/server/draft-order.js.map +1 -1
  212. package/src/lib/server/fulfill-order.js +7 -5
  213. package/src/lib/server/fulfill-order.js.map +1 -1
  214. package/src/lib/server/gift-cards.js +8 -5
  215. package/src/lib/server/gift-cards.js.map +1 -1
  216. package/src/lib/server/local-fulfillment-status.js +9 -6
  217. package/src/lib/server/local-fulfillment-status.js.map +1 -1
  218. package/src/lib/server/member-post.js +6 -5
  219. package/src/lib/server/member-post.js.map +1 -1
  220. package/src/lib/server/membership-admin-password.d.ts +4 -2
  221. package/src/lib/server/membership-admin-password.js +10 -8
  222. package/src/lib/server/membership-admin-password.js.map +1 -1
  223. package/src/lib/server/membership-admin-remove.d.ts +7 -5
  224. package/src/lib/server/membership-admin-remove.js +9 -9
  225. package/src/lib/server/membership-admin-remove.js.map +1 -1
  226. package/src/lib/server/order-notifications.js +5 -2
  227. package/src/lib/server/order-notifications.js.map +1 -1
  228. package/src/lib/server/order-print.js +7 -5
  229. package/src/lib/server/order-print.js.map +1 -1
  230. package/src/lib/server/order-receipt-send.js +8 -5
  231. package/src/lib/server/order-receipt-send.js.map +1 -1
  232. package/src/lib/server/order-webhooks.js +8 -8
  233. package/src/lib/server/order-webhooks.js.map +1 -1
  234. package/src/lib/server/orders-shipping-prepare.js +9 -6
  235. package/src/lib/server/orders-shipping-prepare.js.map +1 -1
  236. package/src/lib/server/own-store-tax-return-source.d.ts +47 -0
  237. package/src/lib/server/own-store-tax-return-source.js +312 -0
  238. package/src/lib/server/own-store-tax-return-source.js.map +1 -0
  239. package/src/lib/server/payment-methods.js +13 -9
  240. package/src/lib/server/payment-methods.js.map +1 -1
  241. package/src/lib/server/pos-auth.d.ts +37 -6
  242. package/src/lib/server/pos-auth.js +40 -15
  243. package/src/lib/server/pos-auth.js.map +1 -1
  244. package/src/lib/server/pos-cellular-billing.d.ts +81 -0
  245. package/src/lib/server/pos-cellular-billing.js +711 -0
  246. package/src/lib/server/pos-cellular-billing.js.map +1 -0
  247. package/src/lib/server/pos-cellular-notify.d.ts +47 -0
  248. package/src/lib/server/pos-cellular-notify.js +150 -0
  249. package/src/lib/server/pos-cellular-notify.js.map +1 -0
  250. package/src/lib/server/pos-cellular.d.ts +88 -0
  251. package/src/lib/server/pos-cellular.js +339 -0
  252. package/src/lib/server/pos-cellular.js.map +1 -0
  253. package/src/lib/server/pos-check-in.d.ts +5 -1
  254. package/src/lib/server/pos-check-in.js +296 -28
  255. package/src/lib/server/pos-check-in.js.map +1 -1
  256. package/src/lib/server/pos-day-report.js +29 -3
  257. package/src/lib/server/pos-day-report.js.map +1 -1
  258. package/src/lib/server/pos-display.d.ts +16 -0
  259. package/src/lib/server/pos-display.js +129 -2
  260. package/src/lib/server/pos-display.js.map +1 -1
  261. package/src/lib/server/pos-hardware-admin.d.ts +10 -1
  262. package/src/lib/server/pos-hardware-admin.js +250 -84
  263. package/src/lib/server/pos-hardware-admin.js.map +1 -1
  264. package/src/lib/server/pos-hardware-attach.d.ts +105 -0
  265. package/src/lib/server/pos-hardware-attach.js +443 -0
  266. package/src/lib/server/pos-hardware-attach.js.map +1 -0
  267. package/src/lib/server/pos-hardware-buyer-lookup.d.ts +58 -0
  268. package/src/lib/server/pos-hardware-buyer-lookup.js +180 -0
  269. package/src/lib/server/pos-hardware-buyer-lookup.js.map +1 -0
  270. package/src/lib/server/pos-hardware-buyer-record.d.ts +29 -0
  271. package/src/lib/server/pos-hardware-buyer-record.js +86 -0
  272. package/src/lib/server/pos-hardware-buyer-record.js.map +1 -0
  273. package/src/lib/server/pos-hardware-cancel.d.ts +58 -0
  274. package/src/lib/server/pos-hardware-cancel.js +147 -0
  275. package/src/lib/server/pos-hardware-cancel.js.map +1 -0
  276. package/src/lib/server/pos-hardware-closure-notices.d.ts +27 -0
  277. package/src/lib/server/pos-hardware-closure-notices.js +85 -0
  278. package/src/lib/server/pos-hardware-closure-notices.js.map +1 -0
  279. package/src/lib/server/pos-hardware-closure.d.ts +60 -0
  280. package/src/lib/server/pos-hardware-closure.js +153 -0
  281. package/src/lib/server/pos-hardware-closure.js.map +1 -0
  282. package/src/lib/server/pos-hardware-in-person.d.ts +61 -0
  283. package/src/lib/server/pos-hardware-in-person.js +236 -0
  284. package/src/lib/server/pos-hardware-in-person.js.map +1 -0
  285. package/src/lib/server/pos-hardware-notify.d.ts +40 -2
  286. package/src/lib/server/pos-hardware-notify.js +195 -14
  287. package/src/lib/server/pos-hardware-notify.js.map +1 -1
  288. package/src/lib/server/pos-hardware-readers.d.ts +115 -0
  289. package/src/lib/server/pos-hardware-readers.js +430 -0
  290. package/src/lib/server/pos-hardware-readers.js.map +1 -0
  291. package/src/lib/server/pos-hardware-returns.d.ts +116 -0
  292. package/src/lib/server/pos-hardware-returns.js +502 -0
  293. package/src/lib/server/pos-hardware-returns.js.map +1 -0
  294. package/src/lib/server/pos-hardware-sale-fields.d.ts +28 -0
  295. package/src/lib/server/pos-hardware-sale-fields.js +44 -0
  296. package/src/lib/server/pos-hardware-sale-fields.js.map +1 -0
  297. package/src/lib/server/pos-hardware-sale.d.ts +54 -0
  298. package/src/lib/server/pos-hardware-sale.js +369 -0
  299. package/src/lib/server/pos-hardware-sale.js.map +1 -0
  300. package/src/lib/server/pos-hardware-tax-return-source.d.ts +99 -0
  301. package/src/lib/server/pos-hardware-tax-return-source.js +462 -0
  302. package/src/lib/server/pos-hardware-tax-return-source.js.map +1 -0
  303. package/src/lib/server/pos-hardware-terms.d.ts +64 -0
  304. package/src/lib/server/pos-hardware-terms.js +154 -0
  305. package/src/lib/server/pos-hardware-terms.js.map +1 -0
  306. package/src/lib/server/pos-hardware-user-eraser.d.ts +3 -0
  307. package/src/lib/server/pos-hardware-user-eraser.js +31 -7
  308. package/src/lib/server/pos-hardware-user-eraser.js.map +1 -1
  309. package/src/lib/server/pos-hardware-webhook.d.ts +5 -0
  310. package/src/lib/server/pos-hardware-webhook.js +51 -6
  311. package/src/lib/server/pos-hardware-webhook.js.map +1 -1
  312. package/src/lib/server/pos-hardware.d.ts +74 -1
  313. package/src/lib/server/pos-hardware.js +175 -10
  314. package/src/lib/server/pos-hardware.js.map +1 -1
  315. package/src/lib/server/pos-kiosk.d.ts +2 -0
  316. package/src/lib/server/pos-kiosk.js +17 -12
  317. package/src/lib/server/pos-kiosk.js.map +1 -1
  318. package/src/lib/server/pos-offline-card-order.d.ts +64 -0
  319. package/src/lib/server/pos-offline-card-order.js +102 -0
  320. package/src/lib/server/pos-offline-card-order.js.map +1 -0
  321. package/src/lib/server/pos-offline-card-reconcile.d.ts +67 -1
  322. package/src/lib/server/pos-offline-card-reconcile.js +215 -18
  323. package/src/lib/server/pos-offline-card-reconcile.js.map +1 -1
  324. package/src/lib/server/pos-offline-sync.d.ts +39 -0
  325. package/src/lib/server/pos-offline-sync.js +190 -55
  326. package/src/lib/server/pos-offline-sync.js.map +1 -1
  327. package/src/lib/server/pos-ops-gate.d.ts +28 -9
  328. package/src/lib/server/pos-ops-gate.js +50 -19
  329. package/src/lib/server/pos-ops-gate.js.map +1 -1
  330. package/src/lib/server/pos-ops-routes.js +24 -0
  331. package/src/lib/server/pos-ops-routes.js.map +1 -1
  332. package/src/lib/server/pos-order-refund-ids.d.ts +28 -0
  333. package/src/lib/server/pos-order-refund-ids.js +31 -0
  334. package/src/lib/server/pos-order-refund-ids.js.map +1 -0
  335. package/src/lib/server/pos-order.js +52 -49
  336. package/src/lib/server/pos-order.js.map +1 -1
  337. package/src/lib/server/pos-payment.js +1 -1
  338. package/src/lib/server/pos-payment.js.map +1 -1
  339. package/src/lib/server/pos-reader-splash-admin.js +30 -32
  340. package/src/lib/server/pos-reader-splash-admin.js.map +1 -1
  341. package/src/lib/server/pos-reader-splash-images-route.d.ts +17 -0
  342. package/src/lib/server/pos-reader-splash-images-route.js +113 -0
  343. package/src/lib/server/pos-reader-splash-images-route.js.map +1 -0
  344. package/src/lib/server/pos-reader-splash-images.d.ts +51 -0
  345. package/src/lib/server/pos-reader-splash-images.js +123 -0
  346. package/src/lib/server/pos-reader-splash-images.js.map +1 -0
  347. package/src/lib/server/pos-reader-splash.d.ts +68 -1
  348. package/src/lib/server/pos-reader-splash.js +182 -11
  349. package/src/lib/server/pos-reader-splash.js.map +1 -1
  350. package/src/lib/server/pos-readers.d.ts +29 -0
  351. package/src/lib/server/pos-readers.js +134 -35
  352. package/src/lib/server/pos-readers.js.map +1 -1
  353. package/src/lib/server/pos-refund-authority.d.ts +3 -1
  354. package/src/lib/server/pos-refund-authority.js +3 -2
  355. package/src/lib/server/pos-refund-authority.js.map +1 -1
  356. package/src/lib/server/pos-return.d.ts +10 -0
  357. package/src/lib/server/pos-return.js +29 -7
  358. package/src/lib/server/pos-return.js.map +1 -1
  359. package/src/lib/server/pos-sale.js +6 -1
  360. package/src/lib/server/pos-sale.js.map +1 -1
  361. package/src/lib/server/pos-shift.js +11 -0
  362. package/src/lib/server/pos-shift.js.map +1 -1
  363. package/src/lib/server/pos-staff-pin.js +29 -24
  364. package/src/lib/server/pos-staff-pin.js.map +1 -1
  365. package/src/lib/server/pos-terminal.d.ts +14 -4
  366. package/src/lib/server/pos-terminal.js +34 -38
  367. package/src/lib/server/pos-terminal.js.map +1 -1
  368. package/src/lib/server/printers.d.ts +7 -3
  369. package/src/lib/server/printers.js +18 -12
  370. package/src/lib/server/printers.js.map +1 -1
  371. package/src/lib/server/product-drafts.d.ts +11 -1
  372. package/src/lib/server/product-drafts.js +12 -8
  373. package/src/lib/server/product-drafts.js.map +1 -1
  374. package/src/lib/server/product.d.ts +15 -1
  375. package/src/lib/server/product.js +16 -3
  376. package/src/lib/server/product.js.map +1 -1
  377. package/src/lib/server/products-write.d.ts +26 -2
  378. package/src/lib/server/products-write.js +19 -7
  379. package/src/lib/server/products-write.js.map +1 -1
  380. package/src/lib/server/refund.js +55 -42
  381. package/src/lib/server/refund.js.map +1 -1
  382. package/src/lib/server/reservation-availability-query.d.ts +8 -0
  383. package/src/lib/server/reservation-availability-query.js +11 -1
  384. package/src/lib/server/reservation-availability-query.js.map +1 -1
  385. package/src/lib/server/reservation-availability.d.ts +1 -1
  386. package/src/lib/server/reservation-availability.js +7 -2
  387. package/src/lib/server/reservation-availability.js.map +1 -1
  388. package/src/lib/server/reservation-guests.d.ts +32 -0
  389. package/src/lib/server/reservation-guests.js +285 -0
  390. package/src/lib/server/reservation-guests.js.map +1 -0
  391. package/src/lib/server/reservation-walk-in.d.ts +11 -1
  392. package/src/lib/server/reservation-walk-in.js +56 -12
  393. package/src/lib/server/reservation-walk-in.js.map +1 -1
  394. package/src/lib/server/reserve.js +18 -5
  395. package/src/lib/server/reserve.js.map +1 -1
  396. package/src/lib/server/returns.js +9 -6
  397. package/src/lib/server/returns.js.map +1 -1
  398. package/src/lib/server/reviews.d.ts +22 -2
  399. package/src/lib/server/reviews.js +88 -20
  400. package/src/lib/server/reviews.js.map +1 -1
  401. package/src/lib/server/shipping-connectors.js +10 -11
  402. package/src/lib/server/shipping-connectors.js.map +1 -1
  403. package/src/lib/server/site-page-resolver.js +20 -3
  404. package/src/lib/server/site-page-resolver.js.map +1 -1
  405. package/src/lib/server/store-day.d.ts +33 -0
  406. package/src/lib/server/store-day.js +46 -0
  407. package/src/lib/server/store-day.js.map +1 -0
  408. package/src/lib/server/store-setup-ai-writer.d.ts +2 -1
  409. package/src/lib/server/store-setup-ai-writer.js +5 -6
  410. package/src/lib/server/store-setup-ai-writer.js.map +1 -1
  411. package/src/lib/server/storefront-tax.d.ts +13 -0
  412. package/src/lib/server/storefront-tax.js +8 -1
  413. package/src/lib/server/storefront-tax.js.map +1 -1
  414. package/src/lib/server/tax-return-source.d.ts +32 -3
  415. package/src/lib/server/tax-return-source.js +99 -20
  416. package/src/lib/server/tax-return-source.js.map +1 -1
  417. package/src/lib/server.js +100 -2
  418. package/src/lib/server.js.map +1 -1
  419. package/src/lib/testing/fake-firestore.js +58 -16
  420. package/src/lib/testing/fake-firestore.js.map +1 -1
  421. package/src/lib/testing/pos-ops-memory-firestore.js +18 -4
  422. package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -1
  423. package/src/lib/testing/site-register-permissions.d.ts +29 -0
  424. package/src/lib/testing/site-register-permissions.js +38 -0
  425. package/src/lib/testing/site-register-permissions.js.map +1 -0
  426. package/src/lib/transfer/tracking.server.js +8 -5
  427. package/src/lib/transfer/tracking.server.js.map +1 -1
  428. package/src/lib/utils/add-to-cart.d.ts +2 -0
  429. package/src/lib/utils/add-to-cart.js +6 -3
  430. package/src/lib/utils/add-to-cart.js.map +1 -1
@@ -0,0 +1,152 @@
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 TaxReturnOperatorSalesPart } from '@aglyn/aglyn/plugin-manager/plugin-tax-return-sources';
18
+ /**
19
+ * The workspace whose stores are the platform's own, from the environment,
20
+ * or `null` when none is named: `POS_HARDWARE_SELLER_ORG_ID`, read whether or
21
+ * not the in-person hardware sale is on, because the workspace is the
22
+ * platform's own either way.
23
+ */
24
+ export declare function platformOwnStoreOrgId(env: Record<string, string | undefined>): string | null;
25
+ /** One of the platform's own stores, as the return reads it. */
26
+ export interface OwnStore {
27
+ hostId: string;
28
+ /** How the breakdown names it. */
29
+ name: string;
30
+ /** Where the store taxes its counter sales from: its own address's region. */
31
+ origin: {
32
+ country?: string | null;
33
+ state?: string | null;
34
+ } | null;
35
+ }
36
+ /** An order of an own store, as the return reads it. */
37
+ export interface OwnStoreOrderInput {
38
+ hostId: string;
39
+ orderId: string;
40
+ status?: unknown;
41
+ channel?: unknown;
42
+ fulfillmentMethod?: unknown;
43
+ channelSource?: {
44
+ taxRemittedByChannel?: unknown;
45
+ } | null;
46
+ totals?: {
47
+ totalCents?: unknown;
48
+ taxCents?: unknown;
49
+ } | null;
50
+ /** Legacy single-product orders. */
51
+ amountCents?: unknown;
52
+ refundedCents?: unknown;
53
+ paidAtMs?: unknown;
54
+ createdAtMs?: unknown;
55
+ cancelledAtMs?: unknown;
56
+ updatedAtMs?: unknown;
57
+ timeline?: Array<{
58
+ atMs?: unknown;
59
+ event?: unknown;
60
+ }> | null;
61
+ livemode?: unknown;
62
+ checkoutSessionId?: unknown;
63
+ payments?: Array<{
64
+ status?: unknown;
65
+ livemode?: unknown;
66
+ }> | null;
67
+ shippingAddress?: {
68
+ country?: unknown;
69
+ state?: unknown;
70
+ } | null;
71
+ billingAddress?: {
72
+ country?: unknown;
73
+ state?: unknown;
74
+ } | null;
75
+ }
76
+ export type OwnStoreChannel = 'online' | 'in-person';
77
+ /** How a row counts in the period. */
78
+ export type OwnStoreInPeriod = 'sale' | 'refund' | 'sale and refund';
79
+ /** One order as the working papers carry it: amounts and the region, no buyer. */
80
+ export interface OwnStoreTaxRow {
81
+ hostId: string;
82
+ store: string;
83
+ orderId: string;
84
+ channel: OwnStoreChannel;
85
+ status: string | null;
86
+ paidAt: string | null;
87
+ jurisdiction: string;
88
+ totalSalesCents: number;
89
+ taxableSalesCents: number;
90
+ /** Whether the base is the one Stripe stated, or the whole sale less tax. */
91
+ taxableBase: 'stated' | 'whole sale' | 'untaxed';
92
+ taxCents: number;
93
+ refundedCents: number;
94
+ refundedAt: string | null;
95
+ inPeriodAs: OwnStoreInPeriod;
96
+ }
97
+ export interface OwnStoreTaxSummary {
98
+ periodStart: string;
99
+ periodEnd: string;
100
+ /** Live sales paid in the period. */
101
+ orders: number;
102
+ totalSalesCents: number;
103
+ /** The parts the return folds into its filing figures, one per store and channel. */
104
+ parts: TaxReturnOperatorSalesPart[];
105
+ excluded: {
106
+ testModeOrders: number;
107
+ /** Sold on an outside marketplace that remits the tax itself. */
108
+ marketplaceRemitted: number;
109
+ };
110
+ attention: {
111
+ untaxedOrders: number;
112
+ ordersMissingRegion: number;
113
+ canceledWithoutRefund: number;
114
+ };
115
+ }
116
+ /** When the order was paid, or null for one that never was. See the module note. */
117
+ export declare function ownStoreOrderPaidAt(order: OwnStoreOrderInput): number | null;
118
+ /** When the order's latest refund was made, or null when nothing was refunded. */
119
+ export declare function ownStoreOrderRefundedAt(order: OwnStoreOrderInput): number | null;
120
+ /**
121
+ * Whether a sale was made in test mode. A register payment states its mode,
122
+ * and every one must be live for the sale to be; otherwise the order's own
123
+ * reading applies, where an order nothing marks is live.
124
+ */
125
+ export declare function ownStoreOrderIsTestMode(order: OwnStoreOrderInput): boolean;
126
+ /** Which of a store's parts an order is in. */
127
+ export declare function ownStoreOrderChannel(order: OwnStoreOrderInput): OwnStoreChannel;
128
+ /** Where an order is taxed. See the module note. */
129
+ export declare function ownStoreOrderJurisdiction(order: OwnStoreOrderInput, store: OwnStore | undefined): string;
130
+ /** The part id a store's channel folds in under. */
131
+ export declare function ownStorePartId(hostId: string, channel: OwnStoreChannel): string;
132
+ /**
133
+ * The period's figures from the own stores' orders read for it.
134
+ * `statedBases` maps an order id to the taxable base Stripe stated for it,
135
+ * where its tax row is in hand.
136
+ */
137
+ export declare function ownStoreTaxSummary(input: {
138
+ stores: readonly OwnStore[];
139
+ orders: readonly OwnStoreOrderInput[];
140
+ period: {
141
+ start: Date;
142
+ end: Date;
143
+ };
144
+ statedBases?: ReadonlyMap<string, number>;
145
+ }): {
146
+ summary: OwnStoreTaxSummary;
147
+ rows: OwnStoreTaxRow[];
148
+ };
149
+ /** The taxable base a Stripe tax row states: the largest line's, since each level restates one base. */
150
+ export declare function statedTaxableBase(lines: ReadonlyArray<{
151
+ taxableAmountCents?: unknown;
152
+ } | null | undefined> | null | undefined): number | null;
@@ -0,0 +1,288 @@
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
+ * THE PLATFORM'S OWN STORES, SUMMED FOR ONE FILING PERIOD (AGL-4038).
18
+ *
19
+ * The platform can sell from a store of its own like any merchant: card
20
+ * readers at an event's register, apparel online, anything it decides to
21
+ * sell later. Every one of those sales is the platform's OWN sale, so they
22
+ * fold into its return's filing figures beside its invoices, whatever the
23
+ * product. This module turns the orders of those stores into the figures the
24
+ * return folds in, one part per store and channel.
25
+ *
26
+ * WHICH STORES ARE THE PLATFORM'S OWN is configuration, never an id in code:
27
+ * every site of the workspace `POS_HARDWARE_SELLER_ORG_ID` names, the
28
+ * workspace the deployment already names as owning its own store
29
+ * ({@link platformOwnStoreOrgId}). A merchant's store is never one of them,
30
+ * so a merchant's sale is never folded in: it stays a facilitated sale on
31
+ * the storefront card.
32
+ *
33
+ * THE RULES, each pinned by `own-store-tax-summary.spec.ts`, the same as the
34
+ * hardware shop's (`pos-hardware-tax-summary.ts`) so the two read alike:
35
+ *
36
+ * - **A sale is in the period it was PAID**, half-open: the order's
37
+ * `paidAtMs`, else its `paid` timeline event, else when it was placed for
38
+ * an order that was paid. Its status today does not move it: an order paid
39
+ * in the period and canceled later is still a sale of that period. An
40
+ * order that was never paid (a voided register sale, a lapsed draft) is no
41
+ * sale at all.
42
+ * - **Total sales** are the receipts excluding the tax: the total less the
43
+ * tax. A tip is outside the total already and is never a sale.
44
+ * - **Taxable sales** are the base Stripe Tax stated for the sale where its
45
+ * tax row is in hand, else the whole sale less tax when tax was charged
46
+ * (the store taxes what it sells), else nothing — and an untaxed sale is
47
+ * counted out loud.
48
+ * - **A refund is in the period it was MADE**, by the latest refund on the
49
+ * order's timeline, stated beside the sales and never netted from them. An
50
+ * order keeps only its latest refund stamp, as the platform's invoices do.
51
+ * The refunded tax is the order's own tax in the refund's share of the
52
+ * total.
53
+ * - **Test-mode sales are not sales**: left out and counted.
54
+ * - **A sale on an outside marketplace that remits the tax itself** is the
55
+ * marketplace's to report: left out and counted.
56
+ * - **Where it is taxed**: a register or pickup sale where the store is; any
57
+ * other where it ships, or the billing address; neither is `unknown`,
58
+ * counted out loud.
59
+ *
60
+ * A card reader sold at the register is in its register sale here, and the
61
+ * hardware section does not fold it in again (`pos-hardware-tax-return-
62
+ * source.ts`); the store's tax rows leave the storefront card
63
+ * (`tax-return-source.ts`). Each sale is counted once.
64
+ *
65
+ * Integer cents throughout. Pure and total: no Firestore, no clock.
66
+ *=========================================*/ import { emptyTaxReturnOperatorFigures } from "@aglyn/aglyn/plugin-manager/plugin-tax-return-sources";
67
+ import { taxJurisdictionKey } from "@aglyn/aglyn/app-utils/tax-jurisdiction-figures";
68
+ import { orderIsTestMode } from "./commerce-orders.js";
69
+ import { POS_HARDWARE_ENV } from "./pos-hardware.js";
70
+ const ORG_ID = /^[A-Za-z0-9_-]{1,128}$/;
71
+ /**
72
+ * The workspace whose stores are the platform's own, from the environment,
73
+ * or `null` when none is named: `POS_HARDWARE_SELLER_ORG_ID`, read whether or
74
+ * not the in-person hardware sale is on, because the workspace is the
75
+ * platform's own either way.
76
+ */ export function platformOwnStoreOrgId(env) {
77
+ var _env_POS_HARDWARE_ENV_sellerOrgId;
78
+ const orgId = String((_env_POS_HARDWARE_ENV_sellerOrgId = env[POS_HARDWARE_ENV.sellerOrgId]) != null ? _env_POS_HARDWARE_ENV_sellerOrgId : '').trim();
79
+ return ORG_ID.test(orgId) ? orgId : null;
80
+ }
81
+ const cents = (value)=>{
82
+ const parsed = Math.round(Number(value != null ? value : 0));
83
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
84
+ };
85
+ const stamp = (value)=>typeof value === 'number' && Number.isFinite(value) ? value : null;
86
+ const text = (value)=>typeof value === 'string' && value ? value : null;
87
+ /** The latest stamp of a timeline event named one of `names`, or null. */ function latestEvent(order, names) {
88
+ let latest = null;
89
+ for (const event of Array.isArray(order.timeline) ? order.timeline : []){
90
+ var _ref;
91
+ if (!names.includes(String((_ref = event == null ? void 0 : event.event) != null ? _ref : ''))) continue;
92
+ const at = stamp(event == null ? void 0 : event.atMs);
93
+ if (at !== null && (latest === null || at > latest)) latest = at;
94
+ }
95
+ return latest;
96
+ }
97
+ /** The first `paid` event, which is when the sale was paid. */ function firstPaidEvent(order) {
98
+ let first = null;
99
+ for (const event of Array.isArray(order.timeline) ? order.timeline : []){
100
+ if ((event == null ? void 0 : event.event) !== 'paid') continue;
101
+ const at = stamp(event == null ? void 0 : event.atMs);
102
+ if (at !== null && (first === null || at < first)) first = at;
103
+ }
104
+ return first;
105
+ }
106
+ /** When the order was paid, or null for one that never was. See the module note. */ export function ownStoreOrderPaidAt(order) {
107
+ var _stamp, _order_status;
108
+ const paid = (_stamp = stamp(order.paidAtMs)) != null ? _stamp : firstPaidEvent(order);
109
+ if (paid !== null) return paid;
110
+ const status = String((_order_status = order.status) != null ? _order_status : '');
111
+ const neverPaid = status === 'pending' || status === 'cancelled' && cents(order.refundedCents) <= 0;
112
+ return neverPaid ? null : stamp(order.createdAtMs);
113
+ }
114
+ /** When the order's latest refund was made, or null when nothing was refunded. */ export function ownStoreOrderRefundedAt(order) {
115
+ var _ref, _ref1, _latestEvent;
116
+ if (cents(order.refundedCents) <= 0) return null;
117
+ return (_ref = (_ref1 = (_latestEvent = latestEvent(order, [
118
+ 'refund',
119
+ 'refunded'
120
+ ])) != null ? _latestEvent : stamp(order.cancelledAtMs)) != null ? _ref1 : stamp(order.updatedAtMs)) != null ? _ref : ownStoreOrderPaidAt(order);
121
+ }
122
+ /**
123
+ * Whether a sale was made in test mode. A register payment states its mode,
124
+ * and every one must be live for the sale to be; otherwise the order's own
125
+ * reading applies, where an order nothing marks is live.
126
+ */ export function ownStoreOrderIsTestMode(order) {
127
+ var _text;
128
+ const modes = (Array.isArray(order.payments) ? order.payments : []).filter((payment)=>(payment == null ? void 0 : payment.status) === 'succeeded' && typeof (payment == null ? void 0 : payment.livemode) === 'boolean').map((payment)=>payment.livemode);
129
+ if (modes.length) return !modes.every(Boolean);
130
+ return orderIsTestMode({
131
+ livemode: order.livemode,
132
+ checkoutSessionId: (_text = text(order.checkoutSessionId)) != null ? _text : undefined,
133
+ $id: order.orderId
134
+ });
135
+ }
136
+ /** Which of a store's parts an order is in. */ export function ownStoreOrderChannel(order) {
137
+ return order.channel === 'pos' ? 'in-person' : 'online';
138
+ }
139
+ /** Where an order is taxed. See the module note. */ export function ownStoreOrderJurisdiction(order, store) {
140
+ var _order_shippingAddress, _order_billingAddress;
141
+ if (ownStoreOrderChannel(order) === 'in-person' || order.fulfillmentMethod === 'pickup') {
142
+ var _ref;
143
+ return taxJurisdictionKey((_ref = store == null ? void 0 : store.origin) != null ? _ref : null);
144
+ }
145
+ const shipped = taxJurisdictionKey((_order_shippingAddress = order.shippingAddress) != null ? _order_shippingAddress : null);
146
+ return shipped !== 'unknown' ? shipped : taxJurisdictionKey((_order_billingAddress = order.billingAddress) != null ? _order_billingAddress : null);
147
+ }
148
+ /** The part id a store's channel folds in under. */ export function ownStorePartId(hostId, channel) {
149
+ return `ownStore:${hostId}:${channel}`;
150
+ }
151
+ function partLabel(store, hostId, channel) {
152
+ const name = (store == null ? void 0 : store.name) || hostId;
153
+ return channel === 'in-person' ? `${name} — sold in person` : `${name} — sold online`;
154
+ }
155
+ /**
156
+ * The period's figures from the own stores' orders read for it.
157
+ * `statedBases` maps an order id to the taxable base Stripe stated for it,
158
+ * where its tax row is in hand.
159
+ */ export function ownStoreTaxSummary(input) {
160
+ var _input_orders;
161
+ const { period } = input;
162
+ const startMs = period.start.getTime();
163
+ const endMs = period.end.getTime();
164
+ const within = (at)=>at !== null && at >= startMs && at < endMs;
165
+ const stores = new Map(input.stores.map((store)=>[
166
+ store.hostId,
167
+ store
168
+ ]));
169
+ const parts = new Map();
170
+ const summary = {
171
+ periodStart: period.start.toISOString(),
172
+ periodEnd: period.end.toISOString(),
173
+ orders: 0,
174
+ totalSalesCents: 0,
175
+ parts: [],
176
+ excluded: {
177
+ testModeOrders: 0,
178
+ marketplaceRemitted: 0
179
+ },
180
+ attention: {
181
+ untaxedOrders: 0,
182
+ ordersMissingRegion: 0,
183
+ canceledWithoutRefund: 0
184
+ }
185
+ };
186
+ const rows = [];
187
+ const seen = new Set();
188
+ for (const order of (_input_orders = input.orders) != null ? _input_orders : []){
189
+ var _parts_get, _part_byJurisdiction, _jurisdiction, _, _ref;
190
+ var _order_channelSource, _order_totals, _order_totals1, _input_statedBases;
191
+ // Only an own store's order, and each once: the reader merges queries.
192
+ if (!(order == null ? void 0 : order.orderId) || !stores.has(order.hostId)) continue;
193
+ const key = `${order.hostId}/${order.orderId}`;
194
+ if (seen.has(key)) continue;
195
+ seen.add(key);
196
+ const paidAt = ownStoreOrderPaidAt(order);
197
+ const refundedAt = ownStoreOrderRefundedAt(order);
198
+ const sale = within(paidAt);
199
+ const refund = within(refundedAt);
200
+ if (!sale && !refund) continue;
201
+ if (ownStoreOrderIsTestMode(order)) {
202
+ if (sale) summary.excluded.testModeOrders += 1;
203
+ continue;
204
+ }
205
+ if (order.channel === 'marketplace' && ((_order_channelSource = order.channelSource) == null ? void 0 : _order_channelSource.taxRemittedByChannel) === true) {
206
+ if (sale) summary.excluded.marketplaceRemitted += 1;
207
+ continue;
208
+ }
209
+ const store = stores.get(order.hostId);
210
+ const channel = ownStoreOrderChannel(order);
211
+ const jurisdiction = ownStoreOrderJurisdiction(order, store);
212
+ const partId = ownStorePartId(order.hostId, channel);
213
+ const part = (_parts_get = parts.get(partId)) != null ? _parts_get : (()=>{
214
+ const created = {
215
+ id: partId,
216
+ label: partLabel(store, order.hostId, channel),
217
+ byJurisdiction: {}
218
+ };
219
+ parts.set(partId, created);
220
+ return created;
221
+ })();
222
+ const bucket = (_ = (_part_byJurisdiction = part.byJurisdiction)[_jurisdiction = jurisdiction]) != null ? _ : _part_byJurisdiction[_jurisdiction] = emptyTaxReturnOperatorFigures();
223
+ const total = cents((_ref = (_order_totals = order.totals) == null ? void 0 : _order_totals.totalCents) != null ? _ref : order.amountCents);
224
+ const tax = Math.min(cents((_order_totals1 = order.totals) == null ? void 0 : _order_totals1.taxCents), total);
225
+ const sales = total - tax;
226
+ const stated = (_input_statedBases = input.statedBases) == null ? void 0 : _input_statedBases.get(order.orderId);
227
+ const taxableBase = typeof stated === 'number' && Number.isFinite(stated) ? 'stated' : tax > 0 ? 'whole sale' : 'untaxed';
228
+ const taxable = taxableBase === 'stated' ? Math.min(cents(stated), sales) : taxableBase === 'whole sale' ? sales : 0;
229
+ if (sale) {
230
+ var _order_status;
231
+ summary.orders += 1;
232
+ summary.totalSalesCents += sales;
233
+ bucket.transactionCount += 1;
234
+ bucket.totalSalesCents += sales;
235
+ bucket.taxableSalesCents += taxable;
236
+ bucket.taxCollectedCents += tax;
237
+ if (tax === 0) summary.attention.untaxedOrders += 1;
238
+ if (jurisdiction === 'unknown') summary.attention.ordersMissingRegion += 1;
239
+ const status = String((_order_status = order.status) != null ? _order_status : '');
240
+ if ((status === 'cancelled' || status === 'refunded') && cents(order.refundedCents) <= 0) {
241
+ summary.attention.canceledWithoutRefund += 1;
242
+ }
243
+ }
244
+ const refunded = Math.min(cents(order.refundedCents), total);
245
+ if (refund) {
246
+ // A whole refund gives back the order's own tax; a partial one is split
247
+ // in the order's own ratio.
248
+ const refundedTax = refunded >= total ? tax : total > 0 ? Math.round(refunded * tax / total) : 0;
249
+ bucket.refundCount += 1;
250
+ bucket.refundedSalesCents += refunded - refundedTax;
251
+ bucket.refundedTaxCents += refundedTax;
252
+ }
253
+ rows.push({
254
+ hostId: order.hostId,
255
+ store: (store == null ? void 0 : store.name) || order.hostId,
256
+ orderId: order.orderId,
257
+ channel,
258
+ status: text(order.status),
259
+ paidAt: paidAt === null ? null : new Date(paidAt).toISOString(),
260
+ jurisdiction,
261
+ totalSalesCents: sales,
262
+ taxableSalesCents: taxable,
263
+ taxableBase,
264
+ taxCents: tax,
265
+ refundedCents: refunded,
266
+ refundedAt: refundedAt === null ? null : new Date(refundedAt).toISOString(),
267
+ inPeriodAs: sale && refund ? 'sale and refund' : sale ? 'sale' : 'refund'
268
+ });
269
+ }
270
+ summary.parts = [
271
+ ...parts.values()
272
+ ];
273
+ return {
274
+ summary,
275
+ rows
276
+ };
277
+ }
278
+ /** The taxable base a Stripe tax row states: the largest line's, since each level restates one base. */ export function statedTaxableBase(lines) {
279
+ let base = null;
280
+ for (const line of lines != null ? lines : []){
281
+ const value = Number(line == null ? void 0 : line.taxableAmountCents);
282
+ if ((line == null ? void 0 : line.taxableAmountCents) === null || (line == null ? void 0 : line.taxableAmountCents) === undefined || !Number.isFinite(value)) continue;
283
+ base = base === null ? Math.round(value) : Math.max(base, Math.round(value));
284
+ }
285
+ return base;
286
+ }
287
+
288
+ //# sourceMappingURL=own-store-tax-summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/own-store-tax-summary.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\n/*==========================================\n * THE PLATFORM'S OWN STORES, SUMMED FOR ONE FILING PERIOD (AGL-4038).\n *\n * The platform can sell from a store of its own like any merchant: card\n * readers at an event's register, apparel online, anything it decides to\n * sell later. Every one of those sales is the platform's OWN sale, so they\n * fold into its return's filing figures beside its invoices, whatever the\n * product. This module turns the orders of those stores into the figures the\n * return folds in, one part per store and channel.\n *\n * WHICH STORES ARE THE PLATFORM'S OWN is configuration, never an id in code:\n * every site of the workspace `POS_HARDWARE_SELLER_ORG_ID` names, the\n * workspace the deployment already names as owning its own store\n * ({@link platformOwnStoreOrgId}). A merchant's store is never one of them,\n * so a merchant's sale is never folded in: it stays a facilitated sale on\n * the storefront card.\n *\n * THE RULES, each pinned by `own-store-tax-summary.spec.ts`, the same as the\n * hardware shop's (`pos-hardware-tax-summary.ts`) so the two read alike:\n *\n * - **A sale is in the period it was PAID**, half-open: the order's\n * `paidAtMs`, else its `paid` timeline event, else when it was placed for\n * an order that was paid. Its status today does not move it: an order paid\n * in the period and canceled later is still a sale of that period. An\n * order that was never paid (a voided register sale, a lapsed draft) is no\n * sale at all.\n * - **Total sales** are the receipts excluding the tax: the total less the\n * tax. A tip is outside the total already and is never a sale.\n * - **Taxable sales** are the base Stripe Tax stated for the sale where its\n * tax row is in hand, else the whole sale less tax when tax was charged\n * (the store taxes what it sells), else nothing — and an untaxed sale is\n * counted out loud.\n * - **A refund is in the period it was MADE**, by the latest refund on the\n * order's timeline, stated beside the sales and never netted from them. An\n * order keeps only its latest refund stamp, as the platform's invoices do.\n * The refunded tax is the order's own tax in the refund's share of the\n * total.\n * - **Test-mode sales are not sales**: left out and counted.\n * - **A sale on an outside marketplace that remits the tax itself** is the\n * marketplace's to report: left out and counted.\n * - **Where it is taxed**: a register or pickup sale where the store is; any\n * other where it ships, or the billing address; neither is `unknown`,\n * counted out loud.\n *\n * A card reader sold at the register is in its register sale here, and the\n * hardware section does not fold it in again (`pos-hardware-tax-return-\n * source.ts`); the store's tax rows leave the storefront card\n * (`tax-return-source.ts`). Each sale is counted once.\n *\n * Integer cents throughout. Pure and total: no Firestore, no clock.\n *=========================================*/\n\nimport {\n emptyTaxReturnOperatorFigures,\n type TaxReturnOperatorFigures,\n type TaxReturnOperatorSalesPart,\n} from '@aglyn/aglyn/plugin-manager/plugin-tax-return-sources'\nimport { taxJurisdictionKey } from '@aglyn/aglyn/app-utils/tax-jurisdiction-figures'\nimport { orderIsTestMode } from './commerce-orders'\nimport { POS_HARDWARE_ENV } from './pos-hardware'\n\nconst ORG_ID = /^[A-Za-z0-9_-]{1,128}$/\n\n/**\n * The workspace whose stores are the platform's own, from the environment,\n * or `null` when none is named: `POS_HARDWARE_SELLER_ORG_ID`, read whether or\n * not the in-person hardware sale is on, because the workspace is the\n * platform's own either way.\n */\nexport function platformOwnStoreOrgId(env: Record<string, string | undefined>): string | null {\n const orgId = String(env[POS_HARDWARE_ENV.sellerOrgId] ?? '').trim()\n return ORG_ID.test(orgId) ? orgId : null\n}\n\n/** One of the platform's own stores, as the return reads it. */\nexport interface OwnStore {\n hostId: string\n /** How the breakdown names it. */\n name: string\n /** Where the store taxes its counter sales from: its own address's region. */\n origin: { country?: string | null; state?: string | null } | null\n}\n\n/** An order of an own store, as the return reads it. */\nexport interface OwnStoreOrderInput {\n hostId: string\n orderId: string\n status?: unknown\n channel?: unknown\n fulfillmentMethod?: unknown\n channelSource?: { taxRemittedByChannel?: unknown } | null\n totals?: { totalCents?: unknown; taxCents?: unknown } | null\n /** Legacy single-product orders. */\n amountCents?: unknown\n refundedCents?: unknown\n paidAtMs?: unknown\n createdAtMs?: unknown\n cancelledAtMs?: unknown\n updatedAtMs?: unknown\n timeline?: Array<{ atMs?: unknown; event?: unknown }> | null\n livemode?: unknown\n checkoutSessionId?: unknown\n payments?: Array<{ status?: unknown; livemode?: unknown }> | null\n shippingAddress?: { country?: unknown; state?: unknown } | null\n billingAddress?: { country?: unknown; state?: unknown } | null\n}\n\nexport type OwnStoreChannel = 'online' | 'in-person'\n\n/** How a row counts in the period. */\nexport type OwnStoreInPeriod = 'sale' | 'refund' | 'sale and refund'\n\n/** One order as the working papers carry it: amounts and the region, no buyer. */\nexport interface OwnStoreTaxRow {\n hostId: string\n store: string\n orderId: string\n channel: OwnStoreChannel\n status: string | null\n paidAt: string | null\n jurisdiction: string\n totalSalesCents: number\n taxableSalesCents: number\n /** Whether the base is the one Stripe stated, or the whole sale less tax. */\n taxableBase: 'stated' | 'whole sale' | 'untaxed'\n taxCents: number\n refundedCents: number\n refundedAt: string | null\n inPeriodAs: OwnStoreInPeriod\n}\n\nexport interface OwnStoreTaxSummary {\n periodStart: string\n periodEnd: string\n /** Live sales paid in the period. */\n orders: number\n totalSalesCents: number\n /** The parts the return folds into its filing figures, one per store and channel. */\n parts: TaxReturnOperatorSalesPart[]\n excluded: {\n testModeOrders: number\n /** Sold on an outside marketplace that remits the tax itself. */\n marketplaceRemitted: number\n }\n attention: {\n untaxedOrders: number\n ordersMissingRegion: number\n canceledWithoutRefund: number\n }\n}\n\nconst cents = (value: unknown): number => {\n const parsed = Math.round(Number(value ?? 0))\n return Number.isFinite(parsed) && parsed > 0 ? parsed : 0\n}\n\nconst stamp = (value: unknown): number | null =>\n typeof value === 'number' && Number.isFinite(value) ? value : null\n\nconst text = (value: unknown): string | null => (typeof value === 'string' && value ? value : null)\n\n/** The latest stamp of a timeline event named one of `names`, or null. */\nfunction latestEvent(order: OwnStoreOrderInput, names: readonly string[]): number | null {\n let latest: number | null = null\n for (const event of Array.isArray(order.timeline) ? order.timeline : []) {\n if (!names.includes(String(event?.event ?? ''))) continue\n const at = stamp(event?.atMs)\n if (at !== null && (latest === null || at > latest)) latest = at\n }\n return latest\n}\n\n/** The first `paid` event, which is when the sale was paid. */\nfunction firstPaidEvent(order: OwnStoreOrderInput): number | null {\n let first: number | null = null\n for (const event of Array.isArray(order.timeline) ? order.timeline : []) {\n if (event?.event !== 'paid') continue\n const at = stamp(event?.atMs)\n if (at !== null && (first === null || at < first)) first = at\n }\n return first\n}\n\n/** When the order was paid, or null for one that never was. See the module note. */\nexport function ownStoreOrderPaidAt(order: OwnStoreOrderInput): number | null {\n const paid = stamp(order.paidAtMs) ?? firstPaidEvent(order)\n if (paid !== null) return paid\n const status = String(order.status ?? '')\n const neverPaid = status === 'pending' || (status === 'cancelled' && cents(order.refundedCents) <= 0)\n return neverPaid ? null : stamp(order.createdAtMs)\n}\n\n/** When the order's latest refund was made, or null when nothing was refunded. */\nexport function ownStoreOrderRefundedAt(order: OwnStoreOrderInput): number | null {\n if (cents(order.refundedCents) <= 0) return null\n return (\n latestEvent(order, ['refund', 'refunded']) ??\n stamp(order.cancelledAtMs) ??\n stamp(order.updatedAtMs) ??\n ownStoreOrderPaidAt(order)\n )\n}\n\n/**\n * Whether a sale was made in test mode. A register payment states its mode,\n * and every one must be live for the sale to be; otherwise the order's own\n * reading applies, where an order nothing marks is live.\n */\nexport function ownStoreOrderIsTestMode(order: OwnStoreOrderInput): boolean {\n const modes = (Array.isArray(order.payments) ? order.payments : [])\n .filter((payment) => payment?.status === 'succeeded' && typeof payment?.livemode === 'boolean')\n .map((payment) => payment.livemode as boolean)\n if (modes.length) return !modes.every(Boolean)\n return orderIsTestMode({\n livemode: order.livemode,\n checkoutSessionId: text(order.checkoutSessionId) ?? undefined,\n $id: order.orderId,\n })\n}\n\n/** Which of a store's parts an order is in. */\nexport function ownStoreOrderChannel(order: OwnStoreOrderInput): OwnStoreChannel {\n return order.channel === 'pos' ? 'in-person' : 'online'\n}\n\n/** Where an order is taxed. See the module note. */\nexport function ownStoreOrderJurisdiction(order: OwnStoreOrderInput, store: OwnStore | undefined): string {\n if (ownStoreOrderChannel(order) === 'in-person' || order.fulfillmentMethod === 'pickup') {\n return taxJurisdictionKey(store?.origin ?? null)\n }\n const shipped = taxJurisdictionKey(order.shippingAddress ?? null)\n return shipped !== 'unknown' ? shipped : taxJurisdictionKey(order.billingAddress ?? null)\n}\n\n/** The part id a store's channel folds in under. */\nexport function ownStorePartId(hostId: string, channel: OwnStoreChannel): string {\n return `ownStore:${hostId}:${channel}`\n}\n\nfunction partLabel(store: OwnStore | undefined, hostId: string, channel: OwnStoreChannel): string {\n const name = store?.name || hostId\n return channel === 'in-person' ? `${name} — sold in person` : `${name} — sold online`\n}\n\n/**\n * The period's figures from the own stores' orders read for it.\n * `statedBases` maps an order id to the taxable base Stripe stated for it,\n * where its tax row is in hand.\n */\nexport function ownStoreTaxSummary(input: {\n stores: readonly OwnStore[]\n orders: readonly OwnStoreOrderInput[]\n period: { start: Date; end: Date }\n statedBases?: ReadonlyMap<string, number>\n}): { summary: OwnStoreTaxSummary; rows: OwnStoreTaxRow[] } {\n const { period } = input\n const startMs = period.start.getTime()\n const endMs = period.end.getTime()\n const within = (at: number | null) => at !== null && at >= startMs && at < endMs\n const stores = new Map(input.stores.map((store) => [store.hostId, store]))\n const parts = new Map<string, TaxReturnOperatorSalesPart>()\n const summary: OwnStoreTaxSummary = {\n periodStart: period.start.toISOString(),\n periodEnd: period.end.toISOString(),\n orders: 0,\n totalSalesCents: 0,\n parts: [],\n excluded: { testModeOrders: 0, marketplaceRemitted: 0 },\n attention: { untaxedOrders: 0, ordersMissingRegion: 0, canceledWithoutRefund: 0 },\n }\n const rows: OwnStoreTaxRow[] = []\n const seen = new Set<string>()\n\n for (const order of input.orders ?? []) {\n // Only an own store's order, and each once: the reader merges queries.\n if (!order?.orderId || !stores.has(order.hostId)) continue\n const key = `${order.hostId}/${order.orderId}`\n if (seen.has(key)) continue\n seen.add(key)\n\n const paidAt = ownStoreOrderPaidAt(order)\n const refundedAt = ownStoreOrderRefundedAt(order)\n const sale = within(paidAt)\n const refund = within(refundedAt)\n if (!sale && !refund) continue\n if (ownStoreOrderIsTestMode(order)) {\n if (sale) summary.excluded.testModeOrders += 1\n continue\n }\n if (order.channel === 'marketplace' && order.channelSource?.taxRemittedByChannel === true) {\n if (sale) summary.excluded.marketplaceRemitted += 1\n continue\n }\n\n const store = stores.get(order.hostId)\n const channel = ownStoreOrderChannel(order)\n const jurisdiction = ownStoreOrderJurisdiction(order, store)\n const partId = ownStorePartId(order.hostId, channel)\n const part =\n parts.get(partId) ??\n (() => {\n const created: TaxReturnOperatorSalesPart = {\n id: partId,\n label: partLabel(store, order.hostId, channel),\n byJurisdiction: {},\n }\n parts.set(partId, created)\n return created\n })()\n const bucket: TaxReturnOperatorFigures = (part.byJurisdiction[jurisdiction] ??= emptyTaxReturnOperatorFigures())\n\n const total = cents(order.totals?.totalCents ?? order.amountCents)\n const tax = Math.min(cents(order.totals?.taxCents), total)\n const sales = total - tax\n const stated = input.statedBases?.get(order.orderId)\n const taxableBase: OwnStoreTaxRow['taxableBase'] =\n typeof stated === 'number' && Number.isFinite(stated) ? 'stated' : tax > 0 ? 'whole sale' : 'untaxed'\n const taxable =\n taxableBase === 'stated' ? Math.min(cents(stated), sales) : taxableBase === 'whole sale' ? sales : 0\n\n if (sale) {\n summary.orders += 1\n summary.totalSalesCents += sales\n bucket.transactionCount += 1\n bucket.totalSalesCents += sales\n bucket.taxableSalesCents += taxable\n bucket.taxCollectedCents += tax\n if (tax === 0) summary.attention.untaxedOrders += 1\n if (jurisdiction === 'unknown') summary.attention.ordersMissingRegion += 1\n const status = String(order.status ?? '')\n if ((status === 'cancelled' || status === 'refunded') && cents(order.refundedCents) <= 0) {\n summary.attention.canceledWithoutRefund += 1\n }\n }\n\n const refunded = Math.min(cents(order.refundedCents), total)\n if (refund) {\n // A whole refund gives back the order's own tax; a partial one is split\n // in the order's own ratio.\n const refundedTax = refunded >= total ? tax : total > 0 ? Math.round((refunded * tax) / total) : 0\n bucket.refundCount += 1\n bucket.refundedSalesCents += refunded - refundedTax\n bucket.refundedTaxCents += refundedTax\n }\n\n rows.push({\n hostId: order.hostId,\n store: store?.name || order.hostId,\n orderId: order.orderId,\n channel,\n status: text(order.status),\n paidAt: paidAt === null ? null : new Date(paidAt).toISOString(),\n jurisdiction,\n totalSalesCents: sales,\n taxableSalesCents: taxable,\n taxableBase,\n taxCents: tax,\n refundedCents: refunded,\n refundedAt: refundedAt === null ? null : new Date(refundedAt).toISOString(),\n inPeriodAs: sale && refund ? 'sale and refund' : sale ? 'sale' : 'refund',\n })\n }\n summary.parts = [...parts.values()]\n return { summary, rows }\n}\n\n/** The taxable base a Stripe tax row states: the largest line's, since each level restates one base. */\nexport function statedTaxableBase(\n lines: ReadonlyArray<{ taxableAmountCents?: unknown } | null | undefined> | null | undefined,\n): number | null {\n let base: number | null = null\n for (const line of lines ?? []) {\n const value = Number(line?.taxableAmountCents)\n if (line?.taxableAmountCents === null || line?.taxableAmountCents === undefined || !Number.isFinite(value)) continue\n base = base === null ? Math.round(value) : Math.max(base, Math.round(value))\n }\n return base\n}\n"],"names":["emptyTaxReturnOperatorFigures","taxJurisdictionKey","orderIsTestMode","POS_HARDWARE_ENV","ORG_ID","platformOwnStoreOrgId","env","orgId","String","sellerOrgId","trim","test","cents","value","parsed","Math","round","Number","isFinite","stamp","text","latestEvent","order","names","latest","event","Array","isArray","timeline","includes","at","atMs","firstPaidEvent","first","ownStoreOrderPaidAt","paid","paidAtMs","status","neverPaid","refundedCents","createdAtMs","ownStoreOrderRefundedAt","cancelledAtMs","updatedAtMs","ownStoreOrderIsTestMode","modes","payments","filter","payment","livemode","map","length","every","Boolean","checkoutSessionId","undefined","$id","orderId","ownStoreOrderChannel","channel","ownStoreOrderJurisdiction","store","fulfillmentMethod","origin","shipped","shippingAddress","billingAddress","ownStorePartId","hostId","partLabel","name","ownStoreTaxSummary","input","period","startMs","start","getTime","endMs","end","within","stores","Map","parts","summary","periodStart","toISOString","periodEnd","orders","totalSalesCents","excluded","testModeOrders","marketplaceRemitted","attention","untaxedOrders","ordersMissingRegion","canceledWithoutRefund","rows","seen","Set","part","jurisdiction","has","key","add","paidAt","refundedAt","sale","refund","channelSource","taxRemittedByChannel","get","partId","created","id","label","byJurisdiction","set","bucket","total","totals","totalCents","amountCents","tax","min","taxCents","sales","stated","statedBases","taxableBase","taxable","transactionCount","taxableSalesCents","taxCollectedCents","refunded","refundedTax","refundCount","refundedSalesCents","refundedTaxCents","push","Date","inPeriodAs","values","statedTaxableBase","lines","base","line","taxableAmountCents","max"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAkD2C,GAE3C,SACEA,6BAA6B,QAGxB,wDAAuD;AAC9D,SAASC,kBAAkB,QAAQ,kDAAiD;AACpF,SAASC,eAAe,QAAQ,uBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAgB;AAEjD,MAAMC,SAAS;AAEf;;;;;CAKC,GACD,OAAO,SAASC,sBAAsBC,GAAuC;QACtDA;IAArB,MAAMC,QAAQC,QAAOF,oCAAAA,GAAG,CAACH,iBAAiBM,WAAW,CAAC,YAAjCH,oCAAqC,IAAII,IAAI;IAClE,OAAON,OAAOO,IAAI,CAACJ,SAASA,QAAQ;AACtC;AA+EA,MAAMK,QAAQ,CAACC;IACb,MAAMC,SAASC,KAAKC,KAAK,CAACC,OAAOJ,gBAAAA,QAAS;IAC1C,OAAOI,OAAOC,QAAQ,CAACJ,WAAWA,SAAS,IAAIA,SAAS;AAC1D;AAEA,MAAMK,QAAQ,CAACN,QACb,OAAOA,UAAU,YA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OA,SAAS,OAAOjI,KAAKC,KAAK,CAACH,SAASE,KAAKoI,GAAG,CAACH,MAAMjI,KAAKC,KAAK,CAACH;IACvE;IACA,OAAOmI;AACT"}
@@ -14,10 +14,84 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import type { HostAccessRole } from '@aglyn/aglyn/foundation/definitions/organization.types';
18
+ import type { PluginOrgPermissionDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-entitlements';
17
19
  import type { PluginPermission } from '@aglyn/aglyn/plugin-manager/plugin-permissions';
20
+ /**
21
+ * The register's finer permissions (AGL-4047), each a part of `managePos`
22
+ * (Use the point of sale). Each REFINES it: never held without it, and,
23
+ * where no custom role or override sets one, it follows `managePos` — so a
24
+ * member keeps exactly the register they had until somebody narrows it.
25
+ */
26
+ export type PosRegisterPermission = 'posSell' | 'posRefund' | 'posDiscount' | 'posCashDrawer' | 'posDevices';
27
+ /**
28
+ * The register's keys and `posBuyHardware`, which stands on its own
29
+ * (AGL-4047): it FOLLOWS `managePos` where no custom role or override sets
30
+ * it, so every member keeps the hardware shop they had, but it may be
31
+ * granted without the register — a bookkeeper who orders the store's readers
32
+ * and never rings a sale.
33
+ */
34
+ export type PosPermission = PosRegisterPermission | 'posBuyHardware';
18
35
  /**
19
36
  * Commerce's plugin-declared permissions (AGL-435) — the reference
20
37
  * adopter. Pure data: the client barrel and /server entry both register
21
38
  * it, so console gating and API-side resolution agree.
22
39
  */
23
40
  export declare const COMMERCE_PERMISSIONS: readonly PluginPermission[];
41
+ /** One finer register key's label, for a refusal or a disabled control's reason. */
42
+ export declare function posPermissionLabel(permission: PosPermission): string;
43
+ /**
44
+ * Whether a resolved permission map allows one of the register's finer
45
+ * actions (AGL-4047): `managePos`, and the finer key not refused. A map
46
+ * that does not carry the finer key at all follows `managePos` — the
47
+ * resolvers always carry it once commerce has registered, so an absent key
48
+ * is a map built before that, which keeps the register it had.
49
+ *
50
+ * `posBuyHardware` stands on its own: its own verdict when the map carries
51
+ * one, granted with or without `managePos`, and `managePos`'s when it does
52
+ * not.
53
+ */
54
+ export declare function holdsPosPermission(permissions: Readonly<Record<string, boolean | undefined>> | null | undefined, permission: PosPermission): boolean;
55
+ /**
56
+ * Whether a member may open the hardware shop at all (AGL-4047): see what
57
+ * it offers and what the store ordered. Whoever works the register, and
58
+ * whoever may buy hardware without working it.
59
+ */
60
+ export declare function mayVisitPosHardwareShop(permissions: Readonly<Record<string, boolean | undefined>> | null | undefined): boolean;
61
+ /** The refusal a register route answers when a finer key is not held. */
62
+ export declare function posPermissionRefusal(permission: PosPermission): string;
63
+ /** The reservation keys. */
64
+ export type ReservationPermission = 'commerce.reservations' | 'commerce.walkIns';
65
+ /** Commerce's keys whose preset is the site role (AGL-4047). */
66
+ export type CommerceSitePermission = ReservationPermission | 'commerce.orders' | 'commerce.giftCards' | 'commerce.paymentMethods' | 'commerce.shippingConnections';
67
+ /** Who held reservations on a site before they were keys: Admin, Editor and Author. */
68
+ export declare const RESERVATION_SITE_ROLE_PRESET: Readonly<Record<HostAccessRole, boolean>>;
69
+ /**
70
+ * Who worked a site's orders and gift cards before they were keys: the site's
71
+ * Admin and Editor (an Author edits the catalog and never touched an order).
72
+ */
73
+ export declare const ORDERS_SITE_ROLE_PRESET: Readonly<Record<HostAccessRole, boolean>>;
74
+ /**
75
+ * Who changed a site's payment methods and its shipping app connections
76
+ * before they were keys: the site's Admin alone (an Editor could see them, as
77
+ * whoever works the orders still can).
78
+ */
79
+ export declare const STORE_SETTINGS_SITE_ROLE_PRESET: Readonly<Record<HostAccessRole, boolean>>;
80
+ /** The same, per workspace role: the answer with no site named. */
81
+ export declare const STORE_SETTINGS_ORG_ROLE_PRESET: {
82
+ readonly owner: true;
83
+ readonly admin: true;
84
+ readonly editor: false;
85
+ readonly viewer: false;
86
+ };
87
+ /**
88
+ * The reservation keys as commerce declares them into the org permission
89
+ * catalog (AGL-4047), registered beside `COMMERCE_PERMISSIONS`.
90
+ */
91
+ export declare const COMMERCE_SITE_PERMISSIONS: readonly PluginOrgPermissionDeclaration[];
92
+ /** The refusal a door answers when a commerce site key is not held: names the permission. */
93
+ export declare function commerceSitePermissionRefusal(key: CommerceSitePermission): string;
94
+ /** One reservation key's label, for a refusal. */
95
+ export declare function reservationPermissionLabel(permission: ReservationPermission): string;
96
+ /** The refusal a reservation route answers when its key is not held; names the permission, never a role. */
97
+ export declare function reservationPermissionRefusal(permission: ReservationPermission): string;