@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.
- package/package.json +13 -13
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/index.js.map +1 -1
- package/src/lib/barcode/barcode-decode.d.ts +71 -0
- package/src/lib/barcode/barcode-decode.js +498 -0
- package/src/lib/barcode/barcode-decode.js.map +1 -0
- package/src/lib/barcode/barcode-encode.d.ts +44 -0
- package/src/lib/barcode/barcode-encode.js +138 -0
- package/src/lib/barcode/barcode-encode.js.map +1 -0
- package/src/lib/barcode/barcode-scanner.component.d.ts +23 -0
- package/src/lib/barcode/barcode-scanner.component.js +260 -0
- package/src/lib/barcode/barcode-scanner.component.js.map +1 -0
- package/src/lib/barcode/scan-button.component.d.ts +10 -0
- package/src/lib/barcode/scan-button.component.js +62 -0
- package/src/lib/barcode/scan-button.component.js.map +1 -0
- package/src/lib/barcode/scanner-wedge.d.ts +35 -0
- package/src/lib/barcode/scanner-wedge.js +108 -0
- package/src/lib/barcode/scanner-wedge.js.map +1 -0
- package/src/lib/components/account.js +10 -1
- package/src/lib/components/account.js.map +1 -1
- package/src/lib/components/cart-extras.d.ts +45 -0
- package/src/lib/components/cart-extras.js +127 -0
- package/src/lib/components/cart-extras.js.map +1 -0
- package/src/lib/components/cart.js +82 -15
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/checkout-return-notice.d.ts +26 -0
- package/src/lib/components/checkout-return-notice.js +48 -0
- package/src/lib/components/checkout-return-notice.js.map +1 -0
- package/src/lib/components/commerce-console-page.js +124 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/commerce-console-sections.d.ts +1 -1
- package/src/lib/components/commerce-console-sections.js +4 -0
- package/src/lib/components/commerce-console-sections.js.map +1 -1
- package/src/lib/components/console/bulk-fulfill.d.ts +44 -0
- package/src/lib/components/console/bulk-fulfill.js +84 -0
- package/src/lib/components/console/bulk-fulfill.js.map +1 -0
- package/src/lib/components/console/catalog-organization-card.component.js +1 -0
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/customer-notifications-card.component.d.ts +19 -0
- package/src/lib/components/console/customer-notifications-card.component.js +149 -0
- package/src/lib/components/console/customer-notifications-card.component.js.map +1 -0
- package/src/lib/components/console/host-orders-card.component.js +88 -6
- package/src/lib/components/console/host-orders-card.component.js.map +1 -1
- package/src/lib/components/console/locations-card.component.js +164 -57
- package/src/lib/components/console/locations-card.component.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +209 -61
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/order-fulfillment-panel.component.d.ts +48 -0
- package/src/lib/components/console/order-fulfillment-panel.component.js +542 -0
- package/src/lib/components/console/order-fulfillment-panel.component.js.map +1 -0
- package/src/lib/components/console/order-invoice.component.d.ts +33 -0
- package/src/lib/components/console/order-invoice.component.js +81 -0
- package/src/lib/components/console/order-invoice.component.js.map +1 -0
- package/src/lib/components/console/order-receipt-resend.component.d.ts +21 -0
- package/src/lib/components/console/order-receipt-resend.component.js +203 -0
- package/src/lib/components/console/order-receipt-resend.component.js.map +1 -0
- package/src/lib/components/console/order-returns.component.d.ts +36 -0
- package/src/lib/components/console/order-returns.component.js +142 -0
- package/src/lib/components/console/order-returns.component.js.map +1 -0
- package/src/lib/components/console/order-shipping-actions.component.d.ts +54 -0
- package/src/lib/components/console/order-shipping-actions.component.js +149 -0
- package/src/lib/components/console/order-shipping-actions.component.js.map +1 -0
- package/src/lib/components/console/order-webhooks-card.component.d.ts +50 -0
- package/src/lib/components/console/order-webhooks-card.component.js +623 -0
- package/src/lib/components/console/order-webhooks-card.component.js.map +1 -0
- package/src/lib/components/console/order-zones.d.ts +155 -0
- package/src/lib/components/console/order-zones.js +40 -0
- package/src/lib/components/console/order-zones.js.map +1 -0
- package/src/lib/components/console/payment-methods-card.component.d.ts +67 -0
- package/src/lib/components/console/payment-methods-card.component.js +395 -0
- package/src/lib/components/console/payment-methods-card.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-api.d.ts +124 -0
- package/src/lib/components/console/pos/pos-api.js +101 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +36 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js +160 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.d.ts +39 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js +352 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-product-grid.component.d.ts +47 -0
- package/src/lib/components/console/pos/pos-product-grid.component.js +272 -0
- package/src/lib/components/console/pos/pos-product-grid.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.d.ts +27 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.js +282 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +53 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +445 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.d.ts +31 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js +640 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/use-pos-display.d.ts +43 -0
- package/src/lib/components/console/pos/use-pos-display.js +161 -0
- package/src/lib/components/console/pos/use-pos-display.js.map +1 -0
- package/src/lib/components/console/pos-devices-card.component.d.ts +14 -0
- package/src/lib/components/console/pos-devices-card.component.js +546 -0
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -0
- package/src/lib/components/console/pos-display/brand-screen.d.ts +33 -0
- package/src/lib/components/console/pos-display/brand-screen.js +85 -0
- package/src/lib/components/console/pos-display/brand-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/cart-screen.d.ts +29 -0
- package/src/lib/components/console/pos-display/cart-screen.js +166 -0
- package/src/lib/components/console/pos-display/cart-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/pairing-screen.d.ts +24 -0
- package/src/lib/components/console/pos-display/pairing-screen.js +127 -0
- package/src/lib/components/console/pos-display/pairing-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/pos-display-api.d.ts +90 -0
- package/src/lib/components/console/pos-display/pos-display-api.js +140 -0
- package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -0
- package/src/lib/components/console/pos-display/receipt-screen.d.ts +35 -0
- package/src/lib/components/console/pos-display/receipt-screen.js +200 -0
- package/src/lib/components/console/pos-display/receipt-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/tip-screen.d.ts +36 -0
- package/src/lib/components/console/pos-display/tip-screen.js +211 -0
- package/src/lib/components/console/pos-display/tip-screen.js.map +1 -0
- package/src/lib/components/console/pos-display-page.component.d.ts +16 -0
- package/src/lib/components/console/pos-display-page.component.js +407 -0
- package/src/lib/components/console/pos-display-page.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.d.ts +40 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js +289 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.d.ts +34 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.js +61 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +38 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +129 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.d.ts +37 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.js +60 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.d.ts +48 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.js +220 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.d.ts +63 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js +186 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-receipt.d.ts +39 -0
- package/src/lib/components/console/pos-ops/pos-receipt.js +182 -0
- package/src/lib/components/console/pos-ops/pos-receipt.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.d.ts +40 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.js +465 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.d.ts +29 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js +253 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +34 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +494 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.d.ts +37 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.js +102 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.d.ts +30 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js +277 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/register-ops.d.ts +28 -0
- package/src/lib/components/console/pos-ops/register-ops.js +28 -0
- package/src/lib/components/console/pos-ops/register-ops.js.map +1 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.d.ts +46 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.js +128 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.js.map +1 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.d.ts +36 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js +64 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js.map +1 -0
- package/src/lib/components/console/pos-page.component.d.ts +13 -5
- package/src/lib/components/console/pos-page.component.js +756 -654
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/pos-zones.d.ts +23 -0
- package/src/lib/components/console/pos-zones.js +31 -0
- package/src/lib/components/console/pos-zones.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.js +61 -71
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-labels-dialog.component.d.ts +13 -0
- package/src/lib/components/console/product-labels-dialog.component.js +197 -0
- package/src/lib/components/console/product-labels-dialog.component.js.map +1 -0
- package/src/lib/components/console/product-register-fields.component.d.ts +19 -0
- package/src/lib/components/console/product-register-fields.component.js +241 -0
- package/src/lib/components/console/product-register-fields.component.js.map +1 -0
- package/src/lib/components/console/product-zones.d.ts +44 -0
- package/src/lib/components/console/product-zones.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +23 -20
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/register-hardware-card.component.d.ts +33 -0
- package/src/lib/components/console/register-hardware-card.component.js +826 -0
- package/src/lib/components/console/register-hardware-card.component.js.map +1 -0
- package/src/lib/components/console/registers-card.component.js +24 -5
- package/src/lib/components/console/registers-card.component.js.map +1 -1
- package/src/lib/components/console/return-actions.d.ts +38 -0
- package/src/lib/components/console/return-actions.js +76 -0
- package/src/lib/components/console/return-actions.js.map +1 -0
- package/src/lib/components/console/return-detail-dialog.component.d.ts +34 -0
- package/src/lib/components/console/return-detail-dialog.component.js +718 -0
- package/src/lib/components/console/return-detail-dialog.component.js.map +1 -0
- package/src/lib/components/console/return-settings-card.component.d.ts +34 -0
- package/src/lib/components/console/return-settings-card.component.js +195 -0
- package/src/lib/components/console/return-settings-card.component.js.map +1 -0
- package/src/lib/components/console/return-zones.d.ts +87 -0
- package/src/lib/components/console/return-zones.js +31 -0
- package/src/lib/components/console/return-zones.js.map +1 -0
- package/src/lib/components/console/returns-card.component.d.ts +45 -0
- package/src/lib/components/console/returns-card.component.js +159 -0
- package/src/lib/components/console/returns-card.component.js.map +1 -0
- package/src/lib/components/console/shipping-settings-card.component.js +161 -5
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/shippingeasy-card.component.d.ts +59 -0
- package/src/lib/components/console/shippingeasy-card.component.js +378 -0
- package/src/lib/components/console/shippingeasy-card.component.js.map +1 -0
- package/src/lib/components/console/shipstation-card.component.d.ts +35 -0
- package/src/lib/components/console/shipstation-card.component.js +345 -0
- package/src/lib/components/console/shipstation-card.component.js.map +1 -0
- package/src/lib/components/console/start-return-dialog.component.d.ts +40 -0
- package/src/lib/components/console/start-return-dialog.component.js +243 -0
- package/src/lib/components/console/start-return-dialog.component.js.map +1 -0
- package/src/lib/components/console/stock-movements-card.component.js +2 -1
- package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +2 -66
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-zones.d.ts +42 -0
- package/src/lib/components/console/store-zones.js +39 -0
- package/src/lib/components/console/store-zones.js.map +1 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js +1 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -1
- package/src/lib/components/order-status.d.ts +36 -0
- package/src/lib/components/order-status.js +502 -0
- package/src/lib/components/order-status.js.map +1 -0
- package/src/lib/components/product-detail.js +41 -2
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/return-request.d.ts +32 -0
- package/src/lib/components/return-request.js +576 -0
- package/src/lib/components/return-request.js.map +1 -0
- package/src/lib/components/storefront-payment-appearance.d.ts +32 -0
- package/src/lib/components/storefront-payment-appearance.js +114 -0
- package/src/lib/components/storefront-payment-appearance.js.map +1 -0
- package/src/lib/components/storefront-payment-element.d.ts +57 -1
- package/src/lib/components/storefront-payment-element.js +332 -33
- package/src/lib/components/storefront-payment-element.js.map +1 -1
- package/src/lib/constants/order-status.d.ts +22 -0
- package/src/lib/constants/order-status.js +22 -0
- package/src/lib/constants/order-status.js.map +1 -0
- package/src/lib/constants/return-request.d.ts +27 -0
- package/src/lib/constants/return-request.js +32 -0
- package/src/lib/constants/return-request.js.map +1 -0
- package/src/lib/constants/stock-movement-query.js +2 -1
- package/src/lib/constants/stock-movement-query.js.map +1 -1
- package/src/lib/declarations.console-server.js +9 -0
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/declarations.server.d.ts +2 -1
- package/src/lib/declarations.server.js +68 -1
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/buyer-notifications.d.ts +59 -0
- package/src/lib/model/buyer-notifications.js +97 -0
- package/src/lib/model/buyer-notifications.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +171 -2
- package/src/lib/model/commerce-orders.js +26 -16
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-payment-methods.d.ts +146 -0
- package/src/lib/model/commerce-payment-methods.js +247 -0
- package/src/lib/model/commerce-payment-methods.js.map +1 -0
- package/src/lib/model/commerce-pos-ops.d.ts +437 -0
- package/src/lib/model/commerce-pos-ops.js +721 -0
- package/src/lib/model/commerce-pos-ops.js.map +1 -0
- package/src/lib/model/commerce-pos.d.ts +263 -0
- package/src/lib/model/commerce-pos.js +375 -0
- package/src/lib/model/commerce-pos.js.map +1 -0
- package/src/lib/model/commerce-printers.d.ts +211 -0
- package/src/lib/model/commerce-printers.js +181 -0
- package/src/lib/model/commerce-printers.js.map +1 -0
- package/src/lib/model/commerce-receipt.d.ts +97 -0
- package/src/lib/model/commerce-receipt.js +180 -0
- package/src/lib/model/commerce-receipt.js.map +1 -0
- package/src/lib/model/commerce-returns.d.ts +207 -0
- package/src/lib/model/commerce-returns.js +300 -0
- package/src/lib/model/commerce-returns.js.map +1 -0
- package/src/lib/model/commerce-shipping.d.ts +44 -1
- package/src/lib/model/commerce-shipping.js +53 -9
- package/src/lib/model/commerce-shipping.js.map +1 -1
- package/src/lib/model/commerce-tax-engine.d.ts +90 -0
- package/src/lib/model/commerce-tax-engine.js +129 -0
- package/src/lib/model/commerce-tax-engine.js.map +1 -0
- package/src/lib/model/commerce.d.ts +91 -2
- package/src/lib/model/commerce.js +89 -1
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +16 -0
- package/src/lib/model/index.js +16 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/order-events.d.ts +154 -0
- package/src/lib/model/order-events.js +153 -0
- package/src/lib/model/order-events.js.map +1 -0
- package/src/lib/model/order-fulfillment.d.ts +117 -0
- package/src/lib/model/order-fulfillment.js +217 -0
- package/src/lib/model/order-fulfillment.js.map +1 -0
- package/src/lib/model/order-history.d.ts +58 -0
- package/src/lib/model/order-history.js +22 -0
- package/src/lib/model/order-history.js.map +1 -0
- package/src/lib/model/order-list-fields.d.ts +9 -1
- package/src/lib/model/order-list-fields.js +7 -1
- package/src/lib/model/order-list-fields.js.map +1 -1
- package/src/lib/model/order-shipping-export.d.ts +91 -0
- package/src/lib/model/order-shipping-export.js +192 -0
- package/src/lib/model/order-shipping-export.js.map +1 -0
- package/src/lib/model/order-status-view.d.ts +103 -0
- package/src/lib/model/order-status-view.js +156 -0
- package/src/lib/model/order-status-view.js.map +1 -0
- package/src/lib/model/order-webhooks.d.ts +142 -0
- package/src/lib/model/order-webhooks.js +91 -0
- package/src/lib/model/order-webhooks.js.map +1 -0
- package/src/lib/model/product-channel.d.ts +56 -0
- package/src/lib/model/product-channel.js +86 -0
- package/src/lib/model/product-channel.js.map +1 -0
- package/src/lib/model/product-modifiers.d.ts +80 -0
- package/src/lib/model/product-modifiers.js +140 -0
- package/src/lib/model/product-modifiers.js.map +1 -0
- package/src/lib/model/product-write.d.ts +186 -0
- package/src/lib/model/product-write.js +116 -0
- package/src/lib/model/product-write.js.map +1 -0
- package/src/lib/model/shippingeasy.d.ts +94 -0
- package/src/lib/model/shippingeasy.js +267 -0
- package/src/lib/model/shippingeasy.js.map +1 -0
- package/src/lib/model/shipstation.d.ts +125 -0
- package/src/lib/model/shipstation.js +399 -0
- package/src/lib/model/shipstation.js.map +1 -0
- package/src/lib/model/smart-collection-reads.d.ts +32 -0
- package/src/lib/model/smart-collection-reads.js +63 -0
- package/src/lib/model/smart-collection-reads.js.map +1 -0
- package/src/lib/model/tracking-url.d.ts +74 -0
- package/src/lib/model/tracking-url.js +159 -0
- package/src/lib/model/tracking-url.js.map +1 -0
- package/src/lib/plugin-config.d.ts +13 -0
- package/src/lib/plugin-config.js +77 -5
- package/src/lib/plugin-config.js.map +1 -1
- package/src/lib/plugin.js +26 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/pos-ops-config.d.ts +39 -0
- package/src/lib/pos-ops-config.js +88 -0
- package/src/lib/pos-ops-config.js.map +1 -0
- package/src/lib/printing/print-document.d.ts +106 -0
- package/src/lib/printing/print-document.js +464 -0
- package/src/lib/printing/print-document.js.map +1 -0
- package/src/lib/printing/product-labels.d.ts +58 -0
- package/src/lib/printing/product-labels.js +116 -0
- package/src/lib/printing/product-labels.js.map +1 -0
- package/src/lib/printing/render-epson.d.ts +57 -0
- package/src/lib/printing/render-epson.js +135 -0
- package/src/lib/printing/render-epson.js.map +1 -0
- package/src/lib/printing/render-star.d.ts +45 -0
- package/src/lib/printing/render-star.js +100 -0
- package/src/lib/printing/render-star.js.map +1 -0
- package/src/lib/printing/render-text.d.ts +25 -0
- package/src/lib/printing/render-text.js +53 -0
- package/src/lib/printing/render-text.js.map +1 -0
- package/src/lib/server/api-v1/openapi.js +27 -4
- package/src/lib/server/api-v1/openapi.js.map +1 -1
- package/src/lib/server/api-v1/order-view.d.ts +67 -0
- package/src/lib/server/api-v1/order-view.js +120 -0
- package/src/lib/server/api-v1/order-view.js.map +1 -0
- package/src/lib/server/api-v1/orders-and-products.js +58 -65
- package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
- package/src/lib/server/billing-webhook.js +135 -28
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +29 -0
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/carrier-rates-availability.d.ts +26 -0
- package/src/lib/server/carrier-rates-availability.js +76 -0
- package/src/lib/server/carrier-rates-availability.js.map +1 -0
- package/src/lib/server/carrier-shipping.d.ts +84 -0
- package/src/lib/server/carrier-shipping.js +135 -0
- package/src/lib/server/carrier-shipping.js.map +1 -0
- package/src/lib/server/cart-checkout.d.ts +2 -0
- package/src/lib/server/cart-checkout.js +226 -22
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/channel-order-updates.d.ts +50 -0
- package/src/lib/server/channel-order-updates.js +290 -0
- package/src/lib/server/channel-order-updates.js.map +1 -0
- package/src/lib/server/channel-orders.d.ts +85 -0
- package/src/lib/server/channel-orders.js +543 -0
- package/src/lib/server/channel-orders.js.map +1 -0
- package/src/lib/server/checkout-extras.d.ts +64 -0
- package/src/lib/server/checkout-extras.js +157 -0
- package/src/lib/server/checkout-extras.js.map +1 -0
- package/src/lib/server/{feed.d.ts → checkout-status.d.ts} +2 -7
- package/src/lib/server/checkout-status.js +111 -0
- package/src/lib/server/checkout-status.js.map +1 -0
- package/src/lib/server/checkout.js +86 -9
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/draft-order.js +34 -5
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/fulfill-order.d.ts +127 -10
- package/src/lib/server/fulfill-order.js +451 -49
- package/src/lib/server/fulfill-order.js.map +1 -1
- package/src/lib/server/legacy-feed.d.ts +28 -0
- package/src/lib/server/legacy-feed.js +52 -0
- package/src/lib/server/legacy-feed.js.map +1 -0
- package/src/lib/server/native-checkout.d.ts +34 -15
- package/src/lib/server/native-checkout.js +32 -17
- package/src/lib/server/native-checkout.js.map +1 -1
- package/src/lib/server/order-event-host-emit.d.ts +23 -0
- package/src/lib/server/order-event-host-emit.js +30 -0
- package/src/lib/server/order-event-host-emit.js.map +1 -0
- package/src/lib/server/order-event-triggers.d.ts +37 -0
- package/src/lib/server/order-event-triggers.js +119 -0
- package/src/lib/server/order-event-triggers.js.map +1 -0
- package/src/lib/server/order-events.d.ts +62 -0
- package/src/lib/server/order-events.js +109 -0
- package/src/lib/server/order-events.js.map +1 -0
- package/src/lib/server/order-history.d.ts +23 -0
- package/src/lib/server/order-history.js +65 -0
- package/src/lib/server/order-history.js.map +1 -0
- package/src/lib/server/order-notifications.d.ts +185 -0
- package/src/lib/server/order-notifications.js +567 -0
- package/src/lib/server/order-notifications.js.map +1 -0
- package/src/lib/server/order-receipt-send.d.ts +39 -0
- package/src/lib/server/order-receipt-send.js +151 -0
- package/src/lib/server/order-receipt-send.js.map +1 -0
- package/src/lib/server/order-status-token.d.ts +31 -0
- package/src/lib/server/order-status-token.js +75 -0
- package/src/lib/server/order-status-token.js.map +1 -0
- package/src/lib/server/order-status.d.ts +58 -0
- package/src/lib/server/order-status.js +141 -0
- package/src/lib/server/order-status.js.map +1 -0
- package/src/lib/server/order-webhooks.d.ts +108 -0
- package/src/lib/server/order-webhooks.js +622 -0
- package/src/lib/server/order-webhooks.js.map +1 -0
- package/src/lib/server/orders-shipping-prepare.d.ts +26 -0
- package/src/lib/server/orders-shipping-prepare.js +121 -0
- package/src/lib/server/orders-shipping-prepare.js.map +1 -0
- package/src/lib/server/payment-method-domains.d.ts +209 -0
- package/src/lib/server/payment-method-domains.js +444 -0
- package/src/lib/server/payment-method-domains.js.map +1 -0
- package/src/lib/server/payment-methods.d.ts +77 -0
- package/src/lib/server/payment-methods.js +284 -0
- package/src/lib/server/payment-methods.js.map +1 -0
- package/src/lib/server/pos-auth.d.ts +50 -0
- package/src/lib/server/pos-auth.js +121 -0
- package/src/lib/server/pos-auth.js.map +1 -0
- package/src/lib/server/pos-customer.d.ts +49 -0
- package/src/lib/server/pos-customer.js +257 -0
- package/src/lib/server/pos-customer.js.map +1 -0
- package/src/lib/server/pos-display.d.ts +57 -0
- package/src/lib/server/pos-display.js +419 -0
- package/src/lib/server/pos-display.js.map +1 -0
- package/src/lib/server/pos-fee-month.d.ts +34 -0
- package/src/lib/server/pos-fee-month.js +36 -0
- package/src/lib/server/pos-fee-month.js.map +1 -0
- package/src/lib/server/pos-ops-gate.d.ts +161 -0
- package/src/lib/server/pos-ops-gate.js +295 -0
- package/src/lib/server/pos-ops-gate.js.map +1 -0
- package/src/lib/server/pos-ops-routes.d.ts +22 -0
- package/src/lib/server/pos-ops-routes.js +36 -0
- package/src/lib/server/pos-ops-routes.js.map +1 -0
- package/src/lib/server/pos-order.d.ts +1 -18
- package/src/lib/server/pos-order.js +222 -42
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.d.ts +39 -0
- package/src/lib/server/pos-payment.js +922 -0
- package/src/lib/server/pos-payment.js.map +1 -0
- package/src/lib/server/pos-print.d.ts +82 -0
- package/src/lib/server/pos-print.js +193 -0
- package/src/lib/server/pos-print.js.map +1 -0
- package/src/lib/server/pos-readers.d.ts +27 -0
- package/src/lib/server/pos-readers.js +276 -0
- package/src/lib/server/pos-readers.js.map +1 -0
- package/src/lib/server/pos-refund-authority.d.ts +60 -0
- package/src/lib/server/pos-refund-authority.js +72 -0
- package/src/lib/server/pos-refund-authority.js.map +1 -0
- package/src/lib/server/pos-return.d.ts +58 -0
- package/src/lib/server/pos-return.js +891 -0
- package/src/lib/server/pos-return.js.map +1 -0
- package/src/lib/server/pos-sale-stamp.d.ts +66 -0
- package/src/lib/server/pos-sale-stamp.js +84 -0
- package/src/lib/server/pos-sale-stamp.js.map +1 -0
- package/src/lib/server/pos-sale.d.ts +170 -0
- package/src/lib/server/pos-sale.js +461 -0
- package/src/lib/server/pos-sale.js.map +1 -0
- package/src/lib/server/pos-shift.d.ts +45 -0
- package/src/lib/server/pos-shift.js +484 -0
- package/src/lib/server/pos-shift.js.map +1 -0
- package/src/lib/server/pos-staff-pin.d.ts +26 -0
- package/src/lib/server/pos-staff-pin.js +339 -0
- package/src/lib/server/pos-staff-pin.js.map +1 -0
- package/src/lib/server/pos-stripe.d.ts +91 -0
- package/src/lib/server/pos-stripe.js +129 -0
- package/src/lib/server/pos-stripe.js.map +1 -0
- package/src/lib/server/pos-terminal-connection-token.d.ts +48 -0
- package/src/lib/server/pos-terminal-connection-token.js +166 -0
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -0
- package/src/lib/server/pos-terminal.d.ts +218 -0
- package/src/lib/server/pos-terminal.js +1014 -0
- package/src/lib/server/pos-terminal.js.map +1 -0
- package/src/lib/server/print-queue.d.ts +124 -0
- package/src/lib/server/print-queue.js +301 -0
- package/src/lib/server/print-queue.js.map +1 -0
- package/src/lib/server/printer-poll.d.ts +75 -0
- package/src/lib/server/printer-poll.js +325 -0
- package/src/lib/server/printer-poll.js.map +1 -0
- package/src/lib/server/printer-secret.d.ts +39 -0
- package/src/lib/server/printer-secret.js +56 -0
- package/src/lib/server/printer-secret.js.map +1 -0
- package/src/lib/server/printers.d.ts +114 -0
- package/src/lib/server/printers.js +546 -0
- package/src/lib/server/printers.js.map +1 -0
- package/src/lib/server/product-catalog.d.ts +42 -0
- package/src/lib/server/product-catalog.js +309 -0
- package/src/lib/server/product-catalog.js.map +1 -0
- package/src/lib/server/product-drafts.d.ts +5 -1
- package/src/lib/server/product-drafts.js +3 -3
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product-writer.d.ts +19 -0
- package/src/lib/server/product-writer.js +261 -0
- package/src/lib/server/product-writer.js.map +1 -0
- package/src/lib/server/products-write.d.ts +61 -0
- package/src/lib/server/products-write.js +375 -0
- package/src/lib/server/products-write.js.map +1 -0
- package/src/lib/server/refund.js +110 -45
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reserve.js +2 -0
- package/src/lib/server/reserve.js.map +1 -1
- package/src/lib/server/return-status-action.d.ts +37 -0
- package/src/lib/server/return-status-action.js +57 -0
- package/src/lib/server/return-status-action.js.map +1 -0
- package/src/lib/server/returns.d.ts +119 -0
- package/src/lib/server/returns.js +938 -0
- package/src/lib/server/returns.js.map +1 -0
- package/src/lib/server/shipment-records.d.ts +36 -0
- package/src/lib/server/shipment-records.js +289 -0
- package/src/lib/server/shipment-records.js.map +1 -0
- package/src/lib/server/shipping-connector-gates.d.ts +40 -0
- package/src/lib/server/shipping-connector-gates.js +97 -0
- package/src/lib/server/shipping-connector-gates.js.map +1 -0
- package/src/lib/server/shipping-connectors.d.ts +29 -0
- package/src/lib/server/shipping-connectors.js +236 -0
- package/src/lib/server/shipping-connectors.js.map +1 -0
- package/src/lib/server/shippingeasy.d.ts +238 -0
- package/src/lib/server/shippingeasy.js +787 -0
- package/src/lib/server/shippingeasy.js.map +1 -0
- package/src/lib/server/shipstation.d.ts +129 -0
- package/src/lib/server/shipstation.js +483 -0
- package/src/lib/server/shipstation.js.map +1 -0
- package/src/lib/server/site-page-resolver.d.ts +5 -0
- package/src/lib/server/site-page-resolver.js +156 -1
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server/stock-levels.d.ts +21 -0
- package/src/lib/server/stock-levels.js +263 -0
- package/src/lib/server/stock-levels.js.map +1 -0
- package/src/lib/server/stripe-refund.d.ts +47 -0
- package/src/lib/server/stripe-refund.js +87 -0
- package/src/lib/server/stripe-refund.js.map +1 -0
- package/src/lib/server/supplier-update.js +46 -5
- package/src/lib/server/supplier-update.js.map +1 -1
- package/src/lib/server/tax-engine-quote.d.ts +47 -0
- package/src/lib/server/tax-engine-quote.js +105 -0
- package/src/lib/server/tax-engine-quote.js.map +1 -0
- package/src/lib/server.js +143 -2
- package/src/lib/server.js.map +1 -1
- package/src/lib/site.js +12 -0
- package/src/lib/site.js.map +1 -1
- package/src/lib/subprocessors.d.ts +26 -0
- package/src/lib/subprocessors.js +50 -0
- package/src/lib/subprocessors.js.map +1 -0
- package/src/lib/tenant-emails.js +461 -3
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-firestore.d.ts +45 -0
- package/src/lib/testing/fake-firestore.js +189 -0
- package/src/lib/testing/fake-firestore.js.map +1 -0
- package/src/lib/testing/memory-firestore.d.ts +136 -0
- package/src/lib/testing/memory-firestore.js +282 -0
- package/src/lib/testing/memory-firestore.js.map +1 -0
- package/src/lib/testing/pos-ops-harness.d.ts +50 -0
- package/src/lib/testing/pos-ops-harness.js +184 -0
- package/src/lib/testing/pos-ops-harness.js.map +1 -0
- package/src/lib/testing/pos-ops-memory-firestore.d.ts +55 -0
- package/src/lib/testing/pos-ops-memory-firestore.js +376 -0
- package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -0
- package/src/lib/transfer/products.server.d.ts +5 -0
- package/src/lib/transfer/products.server.js +2 -2
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/transfer/records-transfer.d.ts +11 -1
- package/src/lib/transfer/records-transfer.js +127 -5
- package/src/lib/transfer/records-transfer.js.map +1 -1
- package/src/lib/transfer/records.server.d.ts +9 -2
- package/src/lib/transfer/records.server.js +58 -7
- package/src/lib/transfer/records.server.js.map +1 -1
- package/src/lib/transfer/register-transfer-resources.js +40 -1
- package/src/lib/transfer/register-transfer-resources.js.map +1 -1
- package/src/lib/transfer/register-transfer-ui.js +4 -1
- package/src/lib/transfer/register-transfer-ui.js.map +1 -1
- package/src/lib/transfer/shipping-presets.d.ts +23 -0
- package/src/lib/transfer/shipping-presets.js +156 -0
- package/src/lib/transfer/shipping-presets.js.map +1 -0
- package/src/lib/transfer/tracking-transfer.d.ts +101 -0
- package/src/lib/transfer/tracking-transfer.js +546 -0
- package/src/lib/transfer/tracking-transfer.js.map +1 -0
- package/src/lib/transfer/tracking.server.d.ts +37 -0
- package/src/lib/transfer/tracking.server.js +393 -0
- package/src/lib/transfer/tracking.server.js.map +1 -0
- package/src/lib/transfer/transfer-keys.d.ts +2 -1
- package/src/lib/transfer/transfer-keys.js +6 -2
- package/src/lib/transfer/transfer-keys.js.map +1 -1
- package/src/lib/utils/code128.d.ts +37 -0
- package/src/lib/utils/code128.js +199 -0
- package/src/lib/utils/code128.js.map +1 -0
- package/src/lib/utils/order-invoice.d.ts +55 -0
- package/src/lib/utils/order-invoice.js +127 -0
- package/src/lib/utils/order-invoice.js.map +1 -0
- package/src/lib/utils/use-checkout-return-notice.d.ts +34 -0
- package/src/lib/utils/use-checkout-return-notice.js +78 -0
- package/src/lib/utils/use-checkout-return-notice.js.map +1 -0
- package/src/lib/server/feed.js +0 -69
- package/src/lib/server/feed.js.map +0 -1
|
@@ -0,0 +1,211 @@
|
|
|
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 { ReceiptData } from './commerce-receipt';
|
|
18
|
+
/**
|
|
19
|
+
* Cloud receipt printers (AGL-3619).
|
|
20
|
+
*
|
|
21
|
+
* A browser register cannot reach a USB or LAN printer without a driver, and
|
|
22
|
+
* an https console cannot talk to a printer's plain-http web service. Both
|
|
23
|
+
* vendors that matter at a counter solve this the same way: the PRINTER polls
|
|
24
|
+
* an https URL, and the server answers with the next job.
|
|
25
|
+
*
|
|
26
|
+
* - Star CloudPRNT (mC-Print3, TSP100IV, mC-Label3): the printer POSTs its
|
|
27
|
+
* status as JSON, GETs the job when told one is ready, and DELETEs it to
|
|
28
|
+
* confirm, with the result in a `code` query parameter.
|
|
29
|
+
* - Epson Server Direct Print (TM-m30III, TM-m50, TM-T88VII): the printer
|
|
30
|
+
* POSTs a form (`ConnectionType=GetRequest`) and receives ePOS-Print XML in
|
|
31
|
+
* the response, then POSTs `ConnectionType=SetResponse` with the result.
|
|
32
|
+
*
|
|
33
|
+
* Every printer belongs to one register and polls one URL that carries the
|
|
34
|
+
* site, the printer and a per-printer secret. The secret is not stored: it is
|
|
35
|
+
* an HMAC of those ids and a rotation counter (`server/printer-secret.ts`), so
|
|
36
|
+
* the console can show it to a manager again and "Regenerate" invalidates the
|
|
37
|
+
* old URL by bumping the counter.
|
|
38
|
+
*
|
|
39
|
+
* `hosts/{hostId}/printers/{printerId}` and `hosts/{hostId}/printJobs/{jobId}`
|
|
40
|
+
* are written only by the server (the Firestore rules deny every client
|
|
41
|
+
* write); the console reads both to show status and recent jobs.
|
|
42
|
+
*/
|
|
43
|
+
export type PrinterBrand = 'star' | 'epson';
|
|
44
|
+
export declare const PRINTER_BRANDS: readonly PrinterBrand[];
|
|
45
|
+
export declare const PRINTER_BRAND_LABELS: Record<PrinterBrand, string>;
|
|
46
|
+
/** The models we document and test against, per brand. Free text is allowed. */
|
|
47
|
+
export declare const PRINTER_MODEL_SUGGESTIONS: Record<PrinterBrand, readonly string[]>;
|
|
48
|
+
/** Roll width; it sets the characters per line. */
|
|
49
|
+
export type PrinterPaperWidth = 80 | 58;
|
|
50
|
+
/** Characters per line in the printer's default font A, by roll width. */
|
|
51
|
+
export declare function printerColumns(paperWidthMm: PrinterPaperWidth | undefined): number;
|
|
52
|
+
/**
|
|
53
|
+
* What the printer last told us about itself. `online` means it can print;
|
|
54
|
+
* `paper_low` still prints. Everything else stops printing until a person
|
|
55
|
+
* fixes it.
|
|
56
|
+
*/
|
|
57
|
+
export type PrinterState = 'online' | 'paper_low' | 'paper_out' | 'cover_open' | 'error' | 'unknown';
|
|
58
|
+
export declare const PRINTER_STATE_LABELS: Record<PrinterState, string>;
|
|
59
|
+
/** A printer that has not polled for this long is shown as offline. */
|
|
60
|
+
export declare const PRINTER_OFFLINE_AFTER_MS: number;
|
|
61
|
+
export interface PrinterStatus {
|
|
62
|
+
state: PrinterState;
|
|
63
|
+
/** The printer's own words, e.g. Star's `410 Out of paper` or Epson's `EPTR_COVER_OPEN`. */
|
|
64
|
+
detail?: string;
|
|
65
|
+
/** Last time the printer polled, ms since epoch. */
|
|
66
|
+
atMs: number;
|
|
67
|
+
/** Polling interval the printer reported (Star `GetPollInterval`), seconds. */
|
|
68
|
+
pollSeconds?: number;
|
|
69
|
+
}
|
|
70
|
+
/** `hosts/{hostId}/printers/{printerId}` (AGL-3619). Server-written only. */
|
|
71
|
+
export interface PosPrinter {
|
|
72
|
+
name: string;
|
|
73
|
+
brand: PrinterBrand;
|
|
74
|
+
model?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The printer's identity as it reports it: the Ethernet MAC for Star
|
|
77
|
+
* (`00:11:62:aa:bb:cc`, lower case), the Server Direct Print `ID` set in
|
|
78
|
+
* Epson's WebConfig. A poll that names a different device is refused, so a
|
|
79
|
+
* leaked URL alone cannot drain the queue from another printer.
|
|
80
|
+
*/
|
|
81
|
+
deviceId: string;
|
|
82
|
+
registerId: string;
|
|
83
|
+
paperWidthMm?: PrinterPaperWidth;
|
|
84
|
+
/** Print a customer receipt when a sale on this register completes. */
|
|
85
|
+
autoPrintReceipts: boolean;
|
|
86
|
+
/** Open the cash drawer wired to this printer on cash sales, cash refunds and paid-outs. */
|
|
87
|
+
kickDrawer: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Print a kitchen (or bar, or packing) ticket for every sale on this
|
|
90
|
+
* register: the order number, each item and quantity, and no prices.
|
|
91
|
+
*/
|
|
92
|
+
kitchenTickets?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The NV logo stored in the printer with the vendor's utility, printed at the
|
|
95
|
+
* top of every receipt: Star's logo number (1-255), Epson's `key1,key2`
|
|
96
|
+
* (e.g. `48,48`). Empty prints no logo.
|
|
97
|
+
*/
|
|
98
|
+
logoKey?: string;
|
|
99
|
+
/** Bumped by "Regenerate URL"; part of the HMAC that makes the secret. */
|
|
100
|
+
secretVersion: number;
|
|
101
|
+
status?: PrinterStatus;
|
|
102
|
+
createdAtMs: number;
|
|
103
|
+
createdBy?: string;
|
|
104
|
+
updatedAtMs?: number;
|
|
105
|
+
}
|
|
106
|
+
export type PrintJobKind = 'receipt' | 'kitchen' | 'drawer' | 'test' | 'report';
|
|
107
|
+
/**
|
|
108
|
+
* A titled report printed on the receipt roll (AGL-3609): a register shift's
|
|
109
|
+
* X or Z report. Rows are already formatted, so every printer prints the
|
|
110
|
+
* figures the console shows.
|
|
111
|
+
*/
|
|
112
|
+
export interface PrintReport {
|
|
113
|
+
title: string;
|
|
114
|
+
storeName: string;
|
|
115
|
+
subtitle?: string;
|
|
116
|
+
sections: Array<{
|
|
117
|
+
section: string;
|
|
118
|
+
rows: Array<{
|
|
119
|
+
label: string;
|
|
120
|
+
value: string;
|
|
121
|
+
strong?: boolean;
|
|
122
|
+
}>;
|
|
123
|
+
}>;
|
|
124
|
+
}
|
|
125
|
+
export type PrintJobStatus = 'queued' | 'printing' | 'done' | 'failed' | 'expired' | 'canceled';
|
|
126
|
+
export declare const PRINT_JOB_ACTIVE_STATUSES: readonly PrintJobStatus[];
|
|
127
|
+
export declare const PRINT_JOB_STATUS_LABELS: Record<PrintJobStatus, string>;
|
|
128
|
+
/** `hosts/{hostId}/printJobs/{jobId}` (AGL-3619). Server-written only. */
|
|
129
|
+
export interface PrintJob {
|
|
130
|
+
printerId: string;
|
|
131
|
+
registerId?: string;
|
|
132
|
+
kind: PrintJobKind;
|
|
133
|
+
status: PrintJobStatus;
|
|
134
|
+
/** The receipt to render; the printer's brand and width decide the bytes at delivery. */
|
|
135
|
+
receipt?: ReceiptData;
|
|
136
|
+
/** The report a `report` job prints. */
|
|
137
|
+
report?: PrintReport;
|
|
138
|
+
/** Open the drawer as this job starts (a cash sale's receipt). */
|
|
139
|
+
openDrawer?: boolean;
|
|
140
|
+
/** The store a test page names. */
|
|
141
|
+
storeName?: string;
|
|
142
|
+
/** IANA zone a test page prints its time in. */
|
|
143
|
+
timeZone?: string;
|
|
144
|
+
orderId?: string;
|
|
145
|
+
/** Why it was printed, for the jobs list: `sale`, `reprint`, `paid_out`, … */
|
|
146
|
+
reason?: string;
|
|
147
|
+
/** Deliveries so far; each GET (Star) or poll hand-off (Epson) counts one. */
|
|
148
|
+
attempts: number;
|
|
149
|
+
createdAtMs: number;
|
|
150
|
+
claimedAtMs?: number;
|
|
151
|
+
finishedAtMs?: number;
|
|
152
|
+
/** After this the job is never delivered: a drawer that opens minutes later is a hazard. */
|
|
153
|
+
deliverByMs: number;
|
|
154
|
+
/** The printer's last result for this job, e.g. `200 OK`, `EPTR_REC_EMPTY`. */
|
|
155
|
+
resultCode?: string;
|
|
156
|
+
error?: string;
|
|
157
|
+
createdBy?: string;
|
|
158
|
+
/** Firestore TTL: the row is removed a week after it is written. */
|
|
159
|
+
expiresAt?: unknown;
|
|
160
|
+
}
|
|
161
|
+
/** A job is re-offered if its printer took it and never confirmed within this. */
|
|
162
|
+
export declare const PRINT_JOB_CLAIM_TIMEOUT_MS: number;
|
|
163
|
+
/** Deliveries before a job that keeps failing is given up on. */
|
|
164
|
+
export declare const PRINT_JOB_MAX_ATTEMPTS = 3;
|
|
165
|
+
/**
|
|
166
|
+
* How long each kind may wait for its printer. A receipt still matters for a
|
|
167
|
+
* while after the customer leaves; a drawer kick must never fire long after
|
|
168
|
+
* the sale that asked for it, because by then the drawer opening is unexpected
|
|
169
|
+
* cash exposure at an unattended till.
|
|
170
|
+
*/
|
|
171
|
+
export declare const PRINT_JOB_DELIVER_WITHIN_MS: Record<PrintJobKind, number>;
|
|
172
|
+
/** Print-job rows are kept for a week, then removed by the Firestore TTL policy. */
|
|
173
|
+
export declare const PRINT_JOB_RETENTION_MS: number;
|
|
174
|
+
/** Star MACs and Epson IDs as we store them. */
|
|
175
|
+
export declare function normalizePrinterDeviceId(brand: PrinterBrand, raw: unknown): string;
|
|
176
|
+
/**
|
|
177
|
+
* A Star status code (`200 OK`, `211 Paper low`, `410%20Out%20of%20paper`) as
|
|
178
|
+
* a printer state. Codes are three or four digits followed by an optional
|
|
179
|
+
* description, URL-encoded because the printer also sends them as a query
|
|
180
|
+
* parameter. Families: 2xx online, 41x paper, 42x cover, 4xx/5xx/1xxx errors.
|
|
181
|
+
*/
|
|
182
|
+
export declare function starPrinterState(rawStatusCode: unknown): {
|
|
183
|
+
state: PrinterState;
|
|
184
|
+
detail: string;
|
|
185
|
+
};
|
|
186
|
+
/** Epson ASB status bits we act on (ePOS-Print XML `<response status>`). */
|
|
187
|
+
export declare const EPSON_ASB: {
|
|
188
|
+
readonly OFFLINE: 8;
|
|
189
|
+
readonly COVER_OPEN: 32;
|
|
190
|
+
readonly MECHANICAL_ERROR: 1024;
|
|
191
|
+
readonly AUTOCUTTER_ERROR: 2048;
|
|
192
|
+
readonly UNRECOVERABLE_ERROR: 8192;
|
|
193
|
+
readonly AUTORECOVER_ERROR: 16384;
|
|
194
|
+
readonly RECEIPT_NEAR_END: 131072;
|
|
195
|
+
readonly RECEIPT_END: 524288;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* An Epson result (`success`, `code`, `status`) as a printer state. The code
|
|
199
|
+
* names the failure when printing failed; the ASB bits say what the printer
|
|
200
|
+
* looks like now, which matters on success too (paper near end).
|
|
201
|
+
*/
|
|
202
|
+
export declare function epsonPrinterState(input: {
|
|
203
|
+
success: boolean;
|
|
204
|
+
code?: string;
|
|
205
|
+
status?: number;
|
|
206
|
+
}): {
|
|
207
|
+
state: PrinterState;
|
|
208
|
+
detail: string;
|
|
209
|
+
};
|
|
210
|
+
/** The state a console row shows: a printer that stopped polling is offline whatever it said last. */
|
|
211
|
+
export declare function printerDisplayState(status: PrinterStatus | undefined, nowMs: number): PrinterState | 'offline';
|
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
*/ export const PRINTER_BRANDS = [
|
|
17
|
+
'star',
|
|
18
|
+
'epson'
|
|
19
|
+
];
|
|
20
|
+
export const PRINTER_BRAND_LABELS = {
|
|
21
|
+
star: 'Star Micronics (CloudPRNT)',
|
|
22
|
+
epson: 'Epson (Server Direct Print)'
|
|
23
|
+
};
|
|
24
|
+
/** The models we document and test against, per brand. Free text is allowed. */ export const PRINTER_MODEL_SUGGESTIONS = {
|
|
25
|
+
star: [
|
|
26
|
+
'mC-Print3',
|
|
27
|
+
'TSP143IV',
|
|
28
|
+
'TSP100IV SK',
|
|
29
|
+
'mC-Label3'
|
|
30
|
+
],
|
|
31
|
+
epson: [
|
|
32
|
+
'TM-m30III',
|
|
33
|
+
'TM-m30II',
|
|
34
|
+
'TM-m50II',
|
|
35
|
+
'TM-T88VII'
|
|
36
|
+
]
|
|
37
|
+
};
|
|
38
|
+
/** Characters per line in the printer's default font A, by roll width. */ export function printerColumns(paperWidthMm) {
|
|
39
|
+
return paperWidthMm === 58 ? 32 : 48;
|
|
40
|
+
}
|
|
41
|
+
export const PRINTER_STATE_LABELS = {
|
|
42
|
+
online: 'Online',
|
|
43
|
+
paper_low: 'Paper low',
|
|
44
|
+
paper_out: 'Out of paper',
|
|
45
|
+
cover_open: 'Cover open',
|
|
46
|
+
error: 'Printer error',
|
|
47
|
+
unknown: 'Waiting for the printer'
|
|
48
|
+
};
|
|
49
|
+
/** A printer that has not polled for this long is shown as offline. */ export const PRINTER_OFFLINE_AFTER_MS = 2 * 60 * 1000;
|
|
50
|
+
export const PRINT_JOB_ACTIVE_STATUSES = [
|
|
51
|
+
'queued',
|
|
52
|
+
'printing'
|
|
53
|
+
];
|
|
54
|
+
export const PRINT_JOB_STATUS_LABELS = {
|
|
55
|
+
queued: 'Waiting',
|
|
56
|
+
printing: 'Printing',
|
|
57
|
+
done: 'Printed',
|
|
58
|
+
failed: 'Failed',
|
|
59
|
+
expired: 'Expired',
|
|
60
|
+
canceled: 'Canceled'
|
|
61
|
+
};
|
|
62
|
+
/** A job is re-offered if its printer took it and never confirmed within this. */ export const PRINT_JOB_CLAIM_TIMEOUT_MS = 90 * 1000;
|
|
63
|
+
/** Deliveries before a job that keeps failing is given up on. */ export const PRINT_JOB_MAX_ATTEMPTS = 3;
|
|
64
|
+
/**
|
|
65
|
+
* How long each kind may wait for its printer. A receipt still matters for a
|
|
66
|
+
* while after the customer leaves; a drawer kick must never fire long after
|
|
67
|
+
* the sale that asked for it, because by then the drawer opening is unexpected
|
|
68
|
+
* cash exposure at an unattended till.
|
|
69
|
+
*/ export const PRINT_JOB_DELIVER_WITHIN_MS = {
|
|
70
|
+
receipt: 30 * 60 * 1000,
|
|
71
|
+
// A ticket that reaches the kitchen long after the order is a meal remade twice.
|
|
72
|
+
kitchen: 10 * 60 * 1000,
|
|
73
|
+
test: 10 * 60 * 1000,
|
|
74
|
+
drawer: 2 * 60 * 1000,
|
|
75
|
+
report: 30 * 60 * 1000
|
|
76
|
+
};
|
|
77
|
+
/** Print-job rows are kept for a week, then removed by the Firestore TTL policy. */ export const PRINT_JOB_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
78
|
+
/** Star MACs and Epson IDs as we store them. */ export function normalizePrinterDeviceId(brand, raw) {
|
|
79
|
+
const value = String(raw != null ? raw : '').trim();
|
|
80
|
+
if (brand === 'star') {
|
|
81
|
+
const hex = value.toLowerCase().replace(/[^0-9a-f]/g, '');
|
|
82
|
+
if (hex.length !== 12) return '';
|
|
83
|
+
return hex.match(/../g).join(':');
|
|
84
|
+
}
|
|
85
|
+
// Epson's WebConfig ID: the same 1-30 safe characters its job ids allow.
|
|
86
|
+
return /^[A-Za-z0-9._-]{1,30}$/.test(value) ? value : '';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A Star status code (`200 OK`, `211 Paper low`, `410%20Out%20of%20paper`) as
|
|
90
|
+
* a printer state. Codes are three or four digits followed by an optional
|
|
91
|
+
* description, URL-encoded because the printer also sends them as a query
|
|
92
|
+
* parameter. Families: 2xx online, 41x paper, 42x cover, 4xx/5xx/1xxx errors.
|
|
93
|
+
*/ export function starPrinterState(rawStatusCode) {
|
|
94
|
+
var _ref;
|
|
95
|
+
var _detail_match;
|
|
96
|
+
let detail = String(rawStatusCode != null ? rawStatusCode : '').trim();
|
|
97
|
+
try {
|
|
98
|
+
detail = decodeURIComponent(detail.replace(/\+/g, ' '));
|
|
99
|
+
} catch (unused) {
|
|
100
|
+
// Not URL-encoded after all; keep the raw text.
|
|
101
|
+
}
|
|
102
|
+
const code = (_ref = (_detail_match = detail.match(/^\d{3,4}/)) == null ? void 0 : _detail_match[0]) != null ? _ref : '';
|
|
103
|
+
if (!code) return {
|
|
104
|
+
state: 'unknown',
|
|
105
|
+
detail
|
|
106
|
+
};
|
|
107
|
+
if (code === '211') return {
|
|
108
|
+
state: 'paper_low',
|
|
109
|
+
detail
|
|
110
|
+
};
|
|
111
|
+
if (code.startsWith('2')) return {
|
|
112
|
+
state: 'online',
|
|
113
|
+
detail
|
|
114
|
+
};
|
|
115
|
+
if (code.length === 3 && code.startsWith('41')) return {
|
|
116
|
+
state: 'paper_out',
|
|
117
|
+
detail
|
|
118
|
+
};
|
|
119
|
+
if (code.length === 3 && code.startsWith('42')) return {
|
|
120
|
+
state: 'cover_open',
|
|
121
|
+
detail
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
state: 'error',
|
|
125
|
+
detail
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** Epson ASB status bits we act on (ePOS-Print XML `<response status>`). */ export const EPSON_ASB = {
|
|
129
|
+
OFFLINE: 0x00000008,
|
|
130
|
+
COVER_OPEN: 0x00000020,
|
|
131
|
+
MECHANICAL_ERROR: 0x00000400,
|
|
132
|
+
AUTOCUTTER_ERROR: 0x00000800,
|
|
133
|
+
UNRECOVERABLE_ERROR: 0x00002000,
|
|
134
|
+
AUTORECOVER_ERROR: 0x00004000,
|
|
135
|
+
RECEIPT_NEAR_END: 0x00020000,
|
|
136
|
+
RECEIPT_END: 0x00080000
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* An Epson result (`success`, `code`, `status`) as a printer state. The code
|
|
140
|
+
* names the failure when printing failed; the ASB bits say what the printer
|
|
141
|
+
* looks like now, which matters on success too (paper near end).
|
|
142
|
+
*/ export function epsonPrinterState(input) {
|
|
143
|
+
var _input_code;
|
|
144
|
+
const code = String((_input_code = input.code) != null ? _input_code : '');
|
|
145
|
+
const status = Number.isFinite(input.status) ? Number(input.status) : 0;
|
|
146
|
+
if (code === 'EPTR_REC_EMPTY' || status & EPSON_ASB.RECEIPT_END) {
|
|
147
|
+
return {
|
|
148
|
+
state: 'paper_out',
|
|
149
|
+
detail: code || 'Roll paper has run out'
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (code === 'EPTR_COVER_OPEN' || status & EPSON_ASB.COVER_OPEN) {
|
|
153
|
+
return {
|
|
154
|
+
state: 'cover_open',
|
|
155
|
+
detail: code || 'Cover is open'
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (!input.success || status & (EPSON_ASB.MECHANICAL_ERROR | EPSON_ASB.AUTOCUTTER_ERROR | EPSON_ASB.UNRECOVERABLE_ERROR | EPSON_ASB.AUTORECOVER_ERROR)) {
|
|
159
|
+
return {
|
|
160
|
+
state: 'error',
|
|
161
|
+
detail: code || 'Printer error'
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
if (status & EPSON_ASB.RECEIPT_NEAR_END) {
|
|
165
|
+
return {
|
|
166
|
+
state: 'paper_low',
|
|
167
|
+
detail: 'Roll paper is nearly out'
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
state: 'online',
|
|
172
|
+
detail: code
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** The state a console row shows: a printer that stopped polling is offline whatever it said last. */ export function printerDisplayState(status, nowMs) {
|
|
176
|
+
if (!(status == null ? void 0 : status.atMs)) return 'unknown';
|
|
177
|
+
if (nowMs - status.atMs > PRINTER_OFFLINE_AFTER_MS) return 'offline';
|
|
178
|
+
return status.state;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//# sourceMappingURL=commerce-printers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/commerce-printers.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReceiptData } from './commerce-receipt'\n\n/**\n * Cloud receipt printers (AGL-3619).\n *\n * A browser register cannot reach a USB or LAN printer without a driver, and\n * an https console cannot talk to a printer's plain-http web service. Both\n * vendors that matter at a counter solve this the same way: the PRINTER polls\n * an https URL, and the server answers with the next job.\n *\n * - Star CloudPRNT (mC-Print3, TSP100IV, mC-Label3): the printer POSTs its\n * status as JSON, GETs the job when told one is ready, and DELETEs it to\n * confirm, with the result in a `code` query parameter.\n * - Epson Server Direct Print (TM-m30III, TM-m50, TM-T88VII): the printer\n * POSTs a form (`ConnectionType=GetRequest`) and receives ePOS-Print XML in\n * the response, then POSTs `ConnectionType=SetResponse` with the result.\n *\n * Every printer belongs to one register and polls one URL that carries the\n * site, the printer and a per-printer secret. The secret is not stored: it is\n * an HMAC of those ids and a rotation counter (`server/printer-secret.ts`), so\n * the console can show it to a manager again and \"Regenerate\" invalidates the\n * old URL by bumping the counter.\n *\n * `hosts/{hostId}/printers/{printerId}` and `hosts/{hostId}/printJobs/{jobId}`\n * are written only by the server (the Firestore rules deny every client\n * write); the console reads both to show status and recent jobs.\n */\n\nexport type PrinterBrand = 'star' | 'epson'\n\nexport const PRINTER_BRANDS: readonly PrinterBrand[] = ['star', 'epson']\n\nexport const PRINTER_BRAND_LABELS: Record<PrinterBrand, string> = {\n star: 'Star Micronics (CloudPRNT)',\n epson: 'Epson (Server Direct Print)',\n}\n\n/** The models we document and test against, per brand. Free text is allowed. */\nexport const PRINTER_MODEL_SUGGESTIONS: Record<PrinterBrand, readonly string[]> = {\n star: ['mC-Print3', 'TSP143IV', 'TSP100IV SK', 'mC-Label3'],\n epson: ['TM-m30III', 'TM-m30II', 'TM-m50II', 'TM-T88VII'],\n}\n\n/** Roll width; it sets the characters per line. */\nexport type PrinterPaperWidth = 80 | 58\n\n/** Characters per line in the printer's default font A, by roll width. */\nexport function printerColumns(paperWidthMm: PrinterPaperWidth | undefined): number {\n return paperWidthMm === 58 ? 32 : 48\n}\n\n/**\n * What the printer last told us about itself. `online` means it can print;\n * `paper_low` still prints. Everything else stops printing until a person\n * fixes it.\n */\nexport type PrinterState =\n | 'online'\n | 'paper_low'\n | 'paper_out'\n | 'cover_open'\n | 'error'\n | 'unknown'\n\nexport const PRINTER_STATE_LABELS: Record<PrinterState, string> = {\n online: 'Online',\n paper_low: 'Paper low',\n paper_out: 'Out of paper',\n cover_open: 'Cover open',\n error: 'Printer error',\n unknown: 'Waiting for the printer',\n}\n\n/** A printer that has not polled for this long is shown as offline. */\nexport const PRINTER_OFFLINE_AFTER_MS = 2 * 60 * 1000\n\nexport interface PrinterStatus {\n state: PrinterState\n /** The printer's own words, e.g. Star's `410 Out of paper` or Epson's `EPTR_COVER_OPEN`. */\n detail?: string\n /** Last time the printer polled, ms since epoch. */\n atMs: number\n /** Polling interval the printer reported (Star `GetPollInterval`), seconds. */\n pollSeconds?: number\n}\n\n/** `hosts/{hostId}/printers/{printerId}` (AGL-3619). Server-written only. */\nexport interface PosPrinter {\n name: string\n brand: PrinterBrand\n model?: string\n /**\n * The printer's identity as it reports it: the Ethernet MAC for Star\n * (`00:11:62:aa:bb:cc`, lower case), the Server Direct Print `ID` set in\n * Epson's WebConfig. A poll that names a different device is refused, so a\n * leaked URL alone cannot drain the queue from another printer.\n */\n deviceId: string\n registerId: string\n paperWidthMm?: PrinterPaperWidth\n /** Print a customer receipt when a sale on this register completes. */\n autoPrintReceipts: boolean\n /** Open the cash drawer wired to this printer on cash sales, cash refunds and paid-outs. */\n kickDrawer: boolean\n /**\n * Print a kitchen (or bar, or packing) ticket for every sale on this\n * register: the order number, each item and quantity, and no prices.\n */\n kitchenTickets?: boolean\n /**\n * The NV logo stored in the printer with the vendor's utility, printed at the\n * top of every receipt: Star's logo number (1-255), Epson's `key1,key2`\n * (e.g. `48,48`). Empty prints no logo.\n */\n logoKey?: string\n /** Bumped by \"Regenerate URL\"; part of the HMAC that makes the secret. */\n secretVersion: number\n status?: PrinterStatus\n createdAtMs: number\n createdBy?: string\n updatedAtMs?: number\n}\n\nexport type PrintJobKind = 'receipt' | 'kitchen' | 'drawer' | 'test' | 'report'\n\n/**\n * A titled report printed on the receipt roll (AGL-3609): a register shift's\n * X or Z report. Rows are already formatted, so every printer prints the\n * figures the console shows.\n */\nexport interface PrintReport {\n title: string\n storeName: string\n subtitle?: string\n sections: Array<{ section: string; rows: Array<{ label: string; value: string; strong?: boolean }> }>\n}\n\nexport type PrintJobStatus = 'queued' | 'printing' | 'done' | 'failed' | 'expired' | 'canceled'\n\nexport const PRINT_JOB_ACTIVE_STATUSES: readonly PrintJobStatus[] = ['queued', 'printing']\n\nexport const PRINT_JOB_STATUS_LABELS: Record<PrintJobStatus, string> = {\n queued: 'Waiting',\n printing: 'Printing',\n done: 'Printed',\n failed: 'Failed',\n expired: 'Expired',\n canceled: 'Canceled',\n}\n\n/** `hosts/{hostId}/printJobs/{jobId}` (AGL-3619). Server-written only. */\nexport interface PrintJob {\n printerId: string\n registerId?: string\n kind: PrintJobKind\n status: PrintJobStatus\n /** The receipt to render; the printer's brand and width decide the bytes at delivery. */\n receipt?: ReceiptData\n /** The report a `report` job prints. */\n report?: PrintReport\n /** Open the drawer as this job starts (a cash sale's receipt). */\n openDrawer?: boolean\n /** The store a test page names. */\n storeName?: string\n /** IANA zone a test page prints its time in. */\n timeZone?: string\n orderId?: string\n /** Why it was printed, for the jobs list: `sale`, `reprint`, `paid_out`, … */\n reason?: string\n /** Deliveries so far; each GET (Star) or poll hand-off (Epson) counts one. */\n attempts: number\n createdAtMs: number\n claimedAtMs?: number\n finishedAtMs?: number\n /** After this the job is never delivered: a drawer that opens minutes later is a hazard. */\n deliverByMs: number\n /** The printer's last result for this job, e.g. `200 OK`, `EPTR_REC_EMPTY`. */\n resultCode?: string\n error?: string\n createdBy?: string\n /** Firestore TTL: the row is removed a week after it is written. */\n expiresAt?: unknown\n}\n\n/** A job is re-offered if its printer took it and never confirmed within this. */\nexport const PRINT_JOB_CLAIM_TIMEOUT_MS = 90 * 1000\n\n/** Deliveries before a job that keeps failing is given up on. */\nexport const PRINT_JOB_MAX_ATTEMPTS = 3\n\n/**\n * How long each kind may wait for its printer. A receipt still matters for a\n * while after the customer leaves; a drawer kick must never fire long after\n * the sale that asked for it, because by then the drawer opening is unexpected\n * cash exposure at an unattended till.\n */\nexport const PRINT_JOB_DELIVER_WITHIN_MS: Record<PrintJobKind, number> = {\n receipt: 30 * 60 * 1000,\n // A ticket that reaches the kitchen long after the order is a meal remade twice.\n kitchen: 10 * 60 * 1000,\n test: 10 * 60 * 1000,\n drawer: 2 * 60 * 1000,\n report: 30 * 60 * 1000,\n}\n\n/** Print-job rows are kept for a week, then removed by the Firestore TTL policy. */\nexport const PRINT_JOB_RETENTION_MS = 7 * 24 * 60 * 60 * 1000\n\n/** Star MACs and Epson IDs as we store them. */\nexport function normalizePrinterDeviceId(brand: PrinterBrand, raw: unknown): string {\n const value = String(raw ?? '').trim()\n if (brand === 'star') {\n const hex = value.toLowerCase().replace(/[^0-9a-f]/g, '')\n if (hex.length !== 12) return ''\n return hex.match(/../g)!.join(':')\n }\n // Epson's WebConfig ID: the same 1-30 safe characters its job ids allow.\n return /^[A-Za-z0-9._-]{1,30}$/.test(value) ? value : ''\n}\n\n/**\n * A Star status code (`200 OK`, `211 Paper low`, `410%20Out%20of%20paper`) as\n * a printer state. Codes are three or four digits followed by an optional\n * description, URL-encoded because the printer also sends them as a query\n * parameter. Families: 2xx online, 41x paper, 42x cover, 4xx/5xx/1xxx errors.\n */\nexport function starPrinterState(rawStatusCode: unknown): { state: PrinterState; detail: string } {\n let detail = String(rawStatusCode ?? '').trim()\n try {\n detail = decodeURIComponent(detail.replace(/\\+/g, ' '))\n } catch {\n // Not URL-encoded after all; keep the raw text.\n }\n const code = detail.match(/^\\d{3,4}/)?.[0] ?? ''\n if (!code) return { state: 'unknown', detail }\n if (code === '211') return { state: 'paper_low', detail }\n if (code.startsWith('2')) return { state: 'online', detail }\n if (code.length === 3 && code.startsWith('41')) return { state: 'paper_out', detail }\n if (code.length === 3 && code.startsWith('42')) return { state: 'cover_open', detail }\n return { state: 'error', detail }\n}\n\n/** Epson ASB status bits we act on (ePOS-Print XML `<response status>`). */\nexport const EPSON_ASB = {\n OFFLINE: 0x00000008,\n COVER_OPEN: 0x00000020,\n MECHANICAL_ERROR: 0x00000400,\n AUTOCUTTER_ERROR: 0x00000800,\n UNRECOVERABLE_ERROR: 0x00002000,\n AUTORECOVER_ERROR: 0x00004000,\n RECEIPT_NEAR_END: 0x00020000,\n RECEIPT_END: 0x00080000,\n} as const\n\n/**\n * An Epson result (`success`, `code`, `status`) as a printer state. The code\n * names the failure when printing failed; the ASB bits say what the printer\n * looks like now, which matters on success too (paper near end).\n */\nexport function epsonPrinterState(input: {\n success: boolean\n code?: string\n status?: number\n}): { state: PrinterState; detail: string } {\n const code = String(input.code ?? '')\n const status = Number.isFinite(input.status) ? Number(input.status) : 0\n if (code === 'EPTR_REC_EMPTY' || status & EPSON_ASB.RECEIPT_END) {\n return { state: 'paper_out', detail: code || 'Roll paper has run out' }\n }\n if (code === 'EPTR_COVER_OPEN' || status & EPSON_ASB.COVER_OPEN) {\n return { state: 'cover_open', detail: code || 'Cover is open' }\n }\n if (\n !input.success ||\n status &\n (EPSON_ASB.MECHANICAL_ERROR |\n EPSON_ASB.AUTOCUTTER_ERROR |\n EPSON_ASB.UNRECOVERABLE_ERROR |\n EPSON_ASB.AUTORECOVER_ERROR)\n ) {\n return { state: 'error', detail: code || 'Printer error' }\n }\n if (status & EPSON_ASB.RECEIPT_NEAR_END) {\n return { state: 'paper_low', detail: 'Roll paper is nearly out' }\n }\n return { state: 'online', detail: code }\n}\n\n/** The state a console row shows: a printer that stopped polling is offline whatever it said last. */\nexport function printerDisplayState(\n status: PrinterStatus | undefined,\n nowMs: number,\n): PrinterState | 'offline' {\n if (!status?.atMs) return 'unknown'\n if (nowMs - status.atMs > PRINTER_OFFLINE_AFTER_MS) return 'offline'\n return status.state\n}\n"],"names":["PRINTER_BRANDS","PRINTER_BRAND_LABELS","star","epson","PRINTER_MODEL_SUGGESTIONS","printerColumns","paperWidthMm","PRINTER_STATE_LABELS","online","paper_low","paper_out","cover_open","error","unknown","PRINTER_OFFLINE_AFTER_MS","PRINT_JOB_ACTIVE_STATUSES","PRINT_JOB_STATUS_LABELS","queued","printing","done","failed","expired","canceled","PRINT_JOB_CLAIM_TIMEOUT_MS","PRINT_JOB_MAX_ATTEMPTS","PRINT_JOB_DELIVER_WITHIN_MS","receipt","kitchen","test","drawer","report","PRINT_JOB_RETENTION_MS","normalizePrinterDeviceId","brand","raw","value","String","trim","hex","toLowerCase","replace","length","match","join","starPrinterState","rawStatusCode","detail","decodeURIComponent","code","state","startsWith","EPSON_ASB","OFFLINE","COVER_OPEN","MECHANICAL_ERROR","AUTOCUTTER_ERROR","UNRECOVERABLE_ERROR","AUTORECOVER_ERROR","RECEIPT_NEAR_END","RECEIPT_END","epsonPrinterState","input","status","Number","isFinite","success","printerDisplayState","nowMs","atMs"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAgCD,OAAO,MAAMA,iBAA0C;IAAC;IAAQ;CAAQ,CAAA;AAExE,OAAO,MAAMC,uBAAqD;IAChEC,MAAM;IACNC,OAAO;AACT,EAAC;AAED,8EAA8E,GAC9E,OAAO,MAAMC,4BAAqE;IAChFF,MAAM;QAAC;QAAa;QAAY;QAAe;KAAY;IAC3DC,OAAO;QAAC;QAAa;QAAY;QAAY;KAAY;AAC3D,EAAC;AAKD,wEAAwE,GACxE,OAAO,SAASE,eAAeC,YAA2C;IACxE,OAAOA,iBAAiB,KAAK,KAAK;AACpC;AAeA,OAAO,MAAMC,uBAAqD;IAChEC,QAAQ;IACRC,WAAW;IACXC,WAAW;IACXC,YAAY;IACZC,OAAO;IACPC,SAAS;AACX,EAAC;AAED,qEAAqE,GACrE,OAAO,MAAMC,2BAA2B,IAAI,KAAK,KAAI;AAiErD,OAAO,MAAMC,4BAAuD;IAAC;IAAU;CAAW,CAAA;AAE1F,OAAO,MAAMC,0BAA0D;IACrEC,QAAQ;IACRC,UAAU;IACVC,MAAM;IACNC,QAAQ;IACRC,SAAS;IACTC,UAAU;AACZ,EAAC;AAoCD,gFAAgF,GAChF,OAAO,MAAMC,6BAA6B,KAAK,KAAI;AAEnD,+DAA+D,GAC/D,OAAO,MAAMC,yBAAyB,EAAC;AAEvC;;;;;CAKC,GACD,OAAO,MAAMC,8BAA4D;IACvEC,SAAS,KAAK,KAAK;IACnB,iFAAiF;IACjFC,SAAS,KAAK,KAAK;IACnBC,MAAM,KAAK,KAAK;IAChBC,QAAQ,IAAI,KAAK;IACjBC,QAAQ,KAAK,KAAK;AACpB,EAAC;AAED,kFAAkF,GAClF,OAAO,MAAMC,yBAAyB,IAAI,KAAK,KAAK,KAAK,KAAI;AAE7D,8CAA8C,GAC9C,OAAO,SAASC,yBAAyBC,KAAmB,EAAEC,GAAY;IACxE,MAAMC,QAAQC,OAAOF,cAAAA,MAAO,IAAIG,IAAI;IACpC,IAAIJ,UAAU,QAAQ;QACpB,MAAMK,MAAMH,MAAMI,WAAW,GAAGC,OAAO,CAAC,cAAc;QACtD,IAAIF,IAAIG,MAAM,KAAK,IAAI,OAAO;QAC9B,OAAOH,IAAII,KAAK,CAAC,OAAQC,IAAI,CAAC;IAChC;IACA,yEAAyE;IACzE,OAAO,yBAAyBf,IAAI,CAACO,SAASA,QAAQ;AACxD;AAEA;;;;;CAKC,GACD,OAAO,SAASS,iBAAiBC,aAAsB;;QAOxCC;IANb,IAAIA,SAASV,OAAOS,wBAAAA,gBAAiB,IAAIR,IAAI;IAC7C,IAAI;QACFS,SAASC,mBAAmBD,OAAON,OAAO,CAAC,OAAO;IACpD,EAAE,eAAM;IACN,gDAAgD;IAClD;IACA,MAAMQ,gBAAOF,gBAAAA,OAAOJ,KAAK,CAAC,gCAAbI,aAA0B,CAAC,EAAE,mBAAI;IAC9C,IAAI,CAACE,MAAM,OAAO;QAAEC,OAAO;QAAWH;IAAO;IAC7C,IAAIE,SAAS,OAAO,OAAO;QAAEC,OAAO;QAAaH;IAAO;IACxD,IAAIE,KAAKE,UAAU,CAAC,MAAM,OAAO;QAAED,OAAO;QAAUH;IAAO;IAC3D,IAAIE,KAAKP,MAAM,KAAK,KAAKO,KAAKE,UAAU,CAAC,OAAO,OAAO;QAAED,OAAO;QAAaH;IAAO;IACpF,IAAIE,KAAKP,MAAM,KAAK,KAAKO,KAAKE,UAAU,CAAC,OAAO,OAAO;QAAED,OAAO;QAAcH;IAAO;IACrF,OAAO;QAAEG,OAAO;QAASH;IAAO;AAClC;AAEA,0EAA0E,GAC1E,OAAO,MAAMK,YAAY;IACvBC,SAAS;IACTC,YAAY;IACZC,kBAAkB;IAClBC,kBAAkB;IAClBC,qBAAqB;IACrBC,mBAAmB;IACnBC,kBAAkB;IAClBC,aAAa;AACf,EAAU;AAEV;;;;CAIC,GACD,OAAO,SAASC,kBAAkBC,KAIjC;QACqBA;IAApB,MAAMb,OAAOZ,QAAOyB,cAAAA,MAAMb,IAAI,YAAVa,cAAc;IAClC,MAAMC,SAASC,OAAOC,QAAQ,CAACH,MAAMC,MAAM,IAAIC,OAAOF,MAAMC,MAAM,IAAI;IACtE,IAAId,SAAS,oBAAoBc,SAASX,UAAUQ,WAAW,EAAE;QAC/D,OAAO;YAAEV,OAAO;YAAaH,QAAQE,QAAQ;QAAyB;IACxE;IACA,IAAIA,SAAS,qBAAqBc,SAASX,UAAUE,UAAU,EAAE;QAC/D,OAAO;YAAEJ,OAAO;YAAcH,QAAQE,QAAQ;QAAgB;IAChE;IACA,IACE,CAACa,MAAMI,OAAO,IACdH,SACGX,CAAAA,UAAUG,gBAAgB,GACzBH,UAAUI,gBAAgB,GAC1BJ,UAAUK,mBAAmB,GAC7BL,UAAUM,iBAAiB,AAAD,GAC9B;QACA,OAAO;YAAER,OAAO;YAASH,QAAQE,QAAQ;QAAgB;IAC3D;IACA,IAAIc,SAASX,UAAUO,gBAAgB,EAAE;QACvC,OAAO;YAAET,OAAO;YAAaH,QAAQ;QAA2B;IAClE;IACA,OAAO;QAAEG,OAAO;QAAUH,QAAQE;IAAK;AACzC;AAEA,oGAAoG,GACpG,OAAO,SAASkB,oBACdJ,MAAiC,EACjCK,KAAa;IAEb,IAAI,EAACL,0BAAAA,OAAQM,IAAI,GAAE,OAAO;IAC1B,IAAID,QAAQL,OAAOM,IAAI,GAAGtD,0BAA0B,OAAO;IAC3D,OAAOgD,OAAOb,KAAK;AACrB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 { HostOrder } from './commerce-orders';
|
|
18
|
+
/**
|
|
19
|
+
* A receipt as DATA (AGL-3619), shared by every surface that prints one: the
|
|
20
|
+
* cloud printer renderers (Star bytes, Epson ePOS-Print XML, plain text) and
|
|
21
|
+
* the 80mm thermal receipt the register shows and prints from the browser
|
|
22
|
+
* (AGL-3609). One model, so a reprint from the console, an auto-print on a
|
|
23
|
+
* sale and the on-screen receipt cannot disagree about what was sold.
|
|
24
|
+
*
|
|
25
|
+
* Amounts are integer minor units in `currency`, and every label is already
|
|
26
|
+
* the words to print: the renderers lay text out, they do not decide it.
|
|
27
|
+
*/
|
|
28
|
+
export interface ReceiptLine {
|
|
29
|
+
name: string;
|
|
30
|
+
/** A variant label or SKU, printed under the name. */
|
|
31
|
+
detail?: string;
|
|
32
|
+
quantity: number;
|
|
33
|
+
unitCents: number;
|
|
34
|
+
totalCents: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ReceiptTender {
|
|
37
|
+
/** e.g. `Cash`, `Visa •••• 4242`, `Gift card`. */
|
|
38
|
+
label: string;
|
|
39
|
+
amountCents: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ReceiptData {
|
|
42
|
+
storeName: string;
|
|
43
|
+
/** Address, phone or website lines under the store name. */
|
|
44
|
+
storeLines?: string[];
|
|
45
|
+
/** The printable order number, e.g. `1042`. */
|
|
46
|
+
orderNumber: string;
|
|
47
|
+
orderId?: string;
|
|
48
|
+
createdAtMs: number;
|
|
49
|
+
/** IANA zone the timestamp is printed in; UTC when absent. */
|
|
50
|
+
timeZone?: string;
|
|
51
|
+
registerName?: string;
|
|
52
|
+
cashierName?: string;
|
|
53
|
+
/** ISO 4217, any case. */
|
|
54
|
+
currency: string;
|
|
55
|
+
lines: ReceiptLine[];
|
|
56
|
+
subtotalCents: number;
|
|
57
|
+
discountCents?: number;
|
|
58
|
+
shippingCents?: number;
|
|
59
|
+
taxCents?: number;
|
|
60
|
+
tipCents?: number;
|
|
61
|
+
totalCents: number;
|
|
62
|
+
tenders?: ReceiptTender[];
|
|
63
|
+
changeCents?: number;
|
|
64
|
+
refundedCents?: number;
|
|
65
|
+
/** Printed small at the bottom: a returns policy, a thank-you. */
|
|
66
|
+
footer?: string;
|
|
67
|
+
/** Code128 under the totals so a return can scan the order back up. Defaults to the order number. */
|
|
68
|
+
barcode?: string;
|
|
69
|
+
/** `REPRINT` / `COPY` banner. */
|
|
70
|
+
banner?: string;
|
|
71
|
+
}
|
|
72
|
+
/** A money amount for print: `$12.50`, `-€3.00`. Locale is fixed so receipts read the same everywhere. */
|
|
73
|
+
export declare function formatReceiptMoney(cents: number, currency: string): string;
|
|
74
|
+
/** The receipt timestamp, e.g. `Oct 6, 2026, 3:04 PM`. */
|
|
75
|
+
export declare function formatReceiptTime(atMs: number, timeZone?: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* The tenders an order was paid with: the register's payment ledger
|
|
78
|
+
* (`payments[]`, AGL-3607) when the order has one, otherwise a single tender
|
|
79
|
+
* read from the order itself (a cash sale's `changeCents`, a QR card sale).
|
|
80
|
+
*/
|
|
81
|
+
export declare function receiptTendersFromOrder(order: HostOrder & Record<string, any>): {
|
|
82
|
+
tenders: ReceiptTender[];
|
|
83
|
+
changeCents: number;
|
|
84
|
+
tipCents: number;
|
|
85
|
+
};
|
|
86
|
+
export interface ReceiptContext {
|
|
87
|
+
storeName: string;
|
|
88
|
+
storeLines?: string[];
|
|
89
|
+
registerName?: string;
|
|
90
|
+
cashierName?: string;
|
|
91
|
+
timeZone?: string;
|
|
92
|
+
currency?: string;
|
|
93
|
+
footer?: string;
|
|
94
|
+
banner?: string;
|
|
95
|
+
}
|
|
96
|
+
/** The receipt an order prints, from the order as stored. */
|
|
97
|
+
export declare function receiptDataFromOrder(orderId: string, order: HostOrder & Record<string, any>, context: ReceiptContext): ReceiptData;
|