@aglyn/plugins-commerce 1.0.0-beta.285 → 1.0.0-beta.287
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/README.md +1 -1
- package/package.json +13 -13
- package/src/lib/components/cart.js +25 -12
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/commerce-console-page.js +70 -13
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +2 -1
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/payment-methods-card.component.js +1 -1
- package/src/lib/components/console/payment-methods-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +5 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js +18 -12
- package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-api.d.ts +76 -5
- package/src/lib/components/console/pos/pos-hardware-api.js +53 -11
- package/src/lib/components/console/pos/pos-hardware-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-hardware-buyer.component.d.ts +18 -0
- package/src/lib/components/console/pos/pos-hardware-buyer.component.js +629 -0
- package/src/lib/components/console/pos/pos-hardware-buyer.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-hardware-sale-api.d.ts +162 -0
- package/src/lib/components/console/pos/pos-hardware-sale-api.js +122 -0
- package/src/lib/components/console/pos/pos-hardware-sale-api.js.map +1 -0
- package/src/lib/components/console/pos/pos-hardware-sale-terms.component.d.ts +39 -0
- package/src/lib/components/console/pos/pos-hardware-sale-terms.component.js +251 -0
- package/src/lib/components/console/pos/pos-hardware-sale-terms.component.js.map +1 -0
- package/src/lib/components/console/pos/use-pos-display.js +50 -0
- package/src/lib/components/console/pos/use-pos-display.js.map +1 -1
- package/src/lib/components/console/pos-cellular-control.component.d.ts +41 -0
- package/src/lib/components/console/pos-cellular-control.component.js +211 -0
- package/src/lib/components/console/pos-cellular-control.component.js.map +1 -0
- package/src/lib/components/console/pos-devices-card.component.d.ts +9 -1
- package/src/lib/components/console/pos-devices-card.component.js +47 -15
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
- package/src/lib/components/console/pos-display/pos-display-api.d.ts +6 -0
- package/src/lib/components/console/pos-display/pos-display-api.js +8 -1
- package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -1
- package/src/lib/components/console/pos-display-page.component.d.ts +13 -0
- package/src/lib/components/console/pos-display-page.component.js +44 -2
- package/src/lib/components/console/pos-display-page.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-card.component.d.ts +12 -4
- package/src/lib/components/console/pos-hardware-card.component.js +157 -36
- package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-orders-staff-page.component.js +360 -80
- package/src/lib/components/console/pos-hardware-orders-staff-page.component.js.map +1 -1
- package/src/lib/components/console/pos-hardware-terms-page.component.d.ts +34 -0
- package/src/lib/components/console/pos-hardware-terms-page.component.js +257 -0
- package/src/lib/components/console/pos-hardware-terms-page.component.js.map +1 -0
- package/src/lib/components/console/pos-hardware-terms-sign-page.component.d.ts +27 -0
- package/src/lib/components/console/pos-hardware-terms-sign-page.component.js +104 -0
- package/src/lib/components/console/pos-hardware-terms-sign-page.component.js.map +1 -0
- package/src/lib/components/console/pos-hardware-waiting-card.component.d.ts +24 -0
- package/src/lib/components/console/pos-hardware-waiting-card.component.js +205 -0
- package/src/lib/components/console/pos-hardware-waiting-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-check-in-dialog.component.js +297 -201
- package/src/lib/components/console/pos-ops/pos-check-in-dialog.component.js.map +1 -1
- package/src/lib/components/console/pos-ops/pos-check-ins-card.component.d.ts +3 -0
- package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js +260 -92
- package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js.map +1 -1
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +9 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +15 -6
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -1
- package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.d.ts +25 -0
- package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.js +136 -0
- package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +6 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +48 -31
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -1
- package/src/lib/components/console/pos-page.component.d.ts +1 -1
- package/src/lib/components/console/pos-page.component.js +63 -12
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/pos-reader-splash-setting.component.js +1 -1
- package/src/lib/components/console/pos-reader-splash-setting.component.js.map +1 -1
- package/src/lib/components/console/product-check-in-fields.component.d.ts +4 -2
- package/src/lib/components/console/product-check-in-fields.component.js +60 -14
- package/src/lib/components/console/product-check-in-fields.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +44 -1
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-hardware-sku-field.component.d.ts +19 -0
- package/src/lib/components/console/product-hardware-sku-field.component.js +92 -0
- package/src/lib/components/console/product-hardware-sku-field.component.js.map +1 -0
- package/src/lib/components/console/product-kiosk-offer-field.component.d.ts +22 -0
- package/src/lib/components/console/product-kiosk-offer-field.component.js +94 -0
- package/src/lib/components/console/product-kiosk-offer-field.component.js.map +1 -0
- package/src/lib/components/console/product-register-fields.component.d.ts +4 -0
- package/src/lib/components/console/product-register-fields.component.js +31 -2
- package/src/lib/components/console/product-register-fields.component.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +11 -2
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/register-hardware-card.component.d.ts +11 -0
- package/src/lib/components/console/register-hardware-card.component.js +56 -27
- package/src/lib/components/console/register-hardware-card.component.js.map +1 -1
- package/src/lib/components/console/reservation-guests-dialog.component.d.ts +28 -0
- package/src/lib/components/console/reservation-guests-dialog.component.js +189 -0
- package/src/lib/components/console/reservation-guests-dialog.component.js.map +1 -0
- package/src/lib/components/console/reservations-card.component.d.ts +9 -0
- package/src/lib/components/console/reservations-card.component.js +158 -23
- package/src/lib/components/console/reservations-card.component.js.map +1 -1
- package/src/lib/components/console/shippingeasy-card.component.js +1 -1
- package/src/lib/components/console/shippingeasy-card.component.js.map +1 -1
- package/src/lib/components/console/shipstation-card.component.d.ts +1 -1
- package/src/lib/components/console/shipstation-card.component.js +3 -3
- package/src/lib/components/console/shipstation-card.component.js.map +1 -1
- package/src/lib/components/product-detail.d.ts +4 -0
- package/src/lib/components/product-detail.js +40 -5
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-reviews.js +28 -11
- package/src/lib/components/product-reviews.js.map +1 -1
- package/src/lib/components/reservation-widget.js +28 -5
- package/src/lib/components/reservation-widget.js.map +1 -1
- package/src/lib/components/use-day-picker.d.ts +25 -0
- package/src/lib/components/use-day-picker.js +57 -0
- package/src/lib/components/use-day-picker.js.map +1 -0
- package/src/lib/constants/operator-alerts.d.ts +55 -0
- package/src/lib/constants/operator-alerts.js +156 -1
- package/src/lib/constants/operator-alerts.js.map +1 -1
- package/src/lib/declarations.console-server.js +54 -1
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/declarations.d.ts +4 -2
- package/src/lib/declarations.js +11 -4
- package/src/lib/declarations.js.map +1 -1
- package/src/lib/declarations.server.js +9 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/commerce-cart.d.ts +9 -1
- package/src/lib/model/commerce-cart.js +4 -3
- package/src/lib/model/commerce-cart.js.map +1 -1
- package/src/lib/model/commerce-check-in-product.d.ts +26 -0
- package/src/lib/model/commerce-check-in-product.js +64 -2
- package/src/lib/model/commerce-check-in-product.js.map +1 -1
- package/src/lib/model/commerce-check-in-record.d.ts +127 -0
- package/src/lib/model/commerce-check-in-record.js +36 -0
- package/src/lib/model/commerce-check-in-record.js.map +1 -0
- package/src/lib/model/commerce-check-in.d.ts +91 -87
- package/src/lib/model/commerce-check-in.js +186 -62
- package/src/lib/model/commerce-check-in.js.map +1 -1
- package/src/lib/model/commerce-kiosk-offer.d.ts +31 -0
- package/src/lib/model/commerce-kiosk-offer.js +35 -0
- package/src/lib/model/commerce-kiosk-offer.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +76 -0
- package/src/lib/model/commerce-orders.js +6 -0
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-pos-day-report.d.ts +54 -1
- package/src/lib/model/commerce-pos-day-report.js +39 -2
- package/src/lib/model/commerce-pos-day-report.js.map +1 -1
- package/src/lib/model/commerce-pos-offline.d.ts +1 -1
- package/src/lib/model/commerce-pos-offline.js +6 -1
- package/src/lib/model/commerce-pos-offline.js.map +1 -1
- package/src/lib/model/commerce-pos-ops.js +3 -2
- package/src/lib/model/commerce-pos-ops.js.map +1 -1
- package/src/lib/model/commerce-pos.d.ts +36 -3
- package/src/lib/model/commerce-pos.js +14 -6
- package/src/lib/model/commerce-pos.js.map +1 -1
- package/src/lib/model/commerce-receipt.js +3 -2
- package/src/lib/model/commerce-receipt.js.map +1 -1
- package/src/lib/model/commerce-reservations.d.ts +69 -4
- package/src/lib/model/commerce-reservations.js +57 -5
- package/src/lib/model/commerce-reservations.js.map +1 -1
- package/src/lib/model/commerce.d.ts +66 -0
- package/src/lib/model/commerce.js +15 -0
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/order-list-fields.d.ts +11 -0
- package/src/lib/model/order-list-fields.js +17 -1
- package/src/lib/model/order-list-fields.js.map +1 -1
- package/src/lib/model/own-store-tax-summary.d.ts +152 -0
- package/src/lib/model/own-store-tax-summary.js +288 -0
- package/src/lib/model/own-store-tax-summary.js.map +1 -0
- package/src/lib/model/plugin-permissions.d.ts +67 -0
- package/src/lib/model/plugin-permissions.js +224 -7
- package/src/lib/model/plugin-permissions.js.map +1 -1
- package/src/lib/model/pos-cellular.d.ts +223 -0
- package/src/lib/model/pos-cellular.js +293 -0
- package/src/lib/model/pos-cellular.js.map +1 -0
- package/src/lib/model/pos-hardware-in-person.d.ts +98 -0
- package/src/lib/model/pos-hardware-in-person.js +224 -0
- package/src/lib/model/pos-hardware-in-person.js.map +1 -0
- package/src/lib/model/pos-hardware-tax-summary.d.ts +166 -0
- package/src/lib/model/pos-hardware-tax-summary.js +225 -0
- package/src/lib/model/pos-hardware-tax-summary.js.map +1 -0
- package/src/lib/model/pos-hardware-terms.d.ts +74 -0
- package/src/lib/model/pos-hardware-terms.js +115 -0
- package/src/lib/model/pos-hardware-terms.js.map +1 -0
- package/src/lib/model/pos-hardware.d.ts +349 -7
- package/src/lib/model/pos-hardware.js +291 -20
- package/src/lib/model/pos-hardware.js.map +1 -1
- package/src/lib/model/product-write.d.ts +10 -0
- package/src/lib/model/product-write.js +4 -2
- package/src/lib/model/product-write.js.map +1 -1
- package/src/lib/plugin.js +16 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/billing-webhook.js +25 -1
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +7 -5
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/cart-checkout.js +20 -8
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/cart.js +29 -0
- package/src/lib/server/cart.js.map +1 -1
- package/src/lib/server/checkout.js +42 -13
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/collection-membership.d.ts +4 -0
- package/src/lib/server/collection-membership.js +5 -10
- package/src/lib/server/collection-membership.js.map +1 -1
- package/src/lib/server/commerce-site-keys.d.ts +29 -0
- package/src/lib/server/commerce-site-keys.js +40 -0
- package/src/lib/server/commerce-site-keys.js.map +1 -0
- package/src/lib/server/draft-order.js +8 -5
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/fulfill-order.js +7 -5
- package/src/lib/server/fulfill-order.js.map +1 -1
- package/src/lib/server/gift-cards.js +8 -5
- package/src/lib/server/gift-cards.js.map +1 -1
- package/src/lib/server/local-fulfillment-status.js +9 -6
- package/src/lib/server/local-fulfillment-status.js.map +1 -1
- package/src/lib/server/member-post.js +6 -5
- package/src/lib/server/member-post.js.map +1 -1
- package/src/lib/server/membership-admin-password.d.ts +4 -2
- package/src/lib/server/membership-admin-password.js +10 -8
- package/src/lib/server/membership-admin-password.js.map +1 -1
- package/src/lib/server/membership-admin-remove.d.ts +7 -5
- package/src/lib/server/membership-admin-remove.js +9 -9
- package/src/lib/server/membership-admin-remove.js.map +1 -1
- package/src/lib/server/order-notifications.js +5 -2
- package/src/lib/server/order-notifications.js.map +1 -1
- package/src/lib/server/order-print.js +7 -5
- package/src/lib/server/order-print.js.map +1 -1
- package/src/lib/server/order-receipt-send.js +8 -5
- package/src/lib/server/order-receipt-send.js.map +1 -1
- package/src/lib/server/orders-shipping-prepare.js +9 -6
- package/src/lib/server/orders-shipping-prepare.js.map +1 -1
- package/src/lib/server/own-store-tax-return-source.d.ts +47 -0
- package/src/lib/server/own-store-tax-return-source.js +312 -0
- package/src/lib/server/own-store-tax-return-source.js.map +1 -0
- package/src/lib/server/payment-methods.js +13 -9
- package/src/lib/server/payment-methods.js.map +1 -1
- package/src/lib/server/pos-auth.d.ts +37 -6
- package/src/lib/server/pos-auth.js +40 -15
- package/src/lib/server/pos-auth.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.d.ts +81 -0
- package/src/lib/server/pos-cellular-billing.js +711 -0
- package/src/lib/server/pos-cellular-billing.js.map +1 -0
- package/src/lib/server/pos-cellular-notify.d.ts +47 -0
- package/src/lib/server/pos-cellular-notify.js +150 -0
- package/src/lib/server/pos-cellular-notify.js.map +1 -0
- package/src/lib/server/pos-cellular.d.ts +88 -0
- package/src/lib/server/pos-cellular.js +339 -0
- package/src/lib/server/pos-cellular.js.map +1 -0
- package/src/lib/server/pos-check-in.d.ts +5 -1
- package/src/lib/server/pos-check-in.js +296 -28
- package/src/lib/server/pos-check-in.js.map +1 -1
- package/src/lib/server/pos-day-report.js +29 -3
- package/src/lib/server/pos-day-report.js.map +1 -1
- package/src/lib/server/pos-display.d.ts +16 -0
- package/src/lib/server/pos-display.js +129 -2
- package/src/lib/server/pos-display.js.map +1 -1
- package/src/lib/server/pos-hardware-admin.d.ts +10 -1
- package/src/lib/server/pos-hardware-admin.js +250 -84
- package/src/lib/server/pos-hardware-admin.js.map +1 -1
- package/src/lib/server/pos-hardware-attach.d.ts +105 -0
- package/src/lib/server/pos-hardware-attach.js +443 -0
- package/src/lib/server/pos-hardware-attach.js.map +1 -0
- package/src/lib/server/pos-hardware-buyer-lookup.d.ts +58 -0
- package/src/lib/server/pos-hardware-buyer-lookup.js +180 -0
- package/src/lib/server/pos-hardware-buyer-lookup.js.map +1 -0
- package/src/lib/server/pos-hardware-buyer-record.d.ts +29 -0
- package/src/lib/server/pos-hardware-buyer-record.js +86 -0
- package/src/lib/server/pos-hardware-buyer-record.js.map +1 -0
- package/src/lib/server/pos-hardware-cancel.d.ts +58 -0
- package/src/lib/server/pos-hardware-cancel.js +147 -0
- package/src/lib/server/pos-hardware-cancel.js.map +1 -0
- package/src/lib/server/pos-hardware-closure-notices.d.ts +27 -0
- package/src/lib/server/pos-hardware-closure-notices.js +85 -0
- package/src/lib/server/pos-hardware-closure-notices.js.map +1 -0
- package/src/lib/server/pos-hardware-closure.d.ts +60 -0
- package/src/lib/server/pos-hardware-closure.js +153 -0
- package/src/lib/server/pos-hardware-closure.js.map +1 -0
- package/src/lib/server/pos-hardware-in-person.d.ts +61 -0
- package/src/lib/server/pos-hardware-in-person.js +236 -0
- package/src/lib/server/pos-hardware-in-person.js.map +1 -0
- package/src/lib/server/pos-hardware-notify.d.ts +40 -2
- package/src/lib/server/pos-hardware-notify.js +195 -14
- package/src/lib/server/pos-hardware-notify.js.map +1 -1
- package/src/lib/server/pos-hardware-readers.d.ts +115 -0
- package/src/lib/server/pos-hardware-readers.js +430 -0
- package/src/lib/server/pos-hardware-readers.js.map +1 -0
- package/src/lib/server/pos-hardware-returns.d.ts +116 -0
- package/src/lib/server/pos-hardware-returns.js +502 -0
- package/src/lib/server/pos-hardware-returns.js.map +1 -0
- package/src/lib/server/pos-hardware-sale-fields.d.ts +28 -0
- package/src/lib/server/pos-hardware-sale-fields.js +44 -0
- package/src/lib/server/pos-hardware-sale-fields.js.map +1 -0
- package/src/lib/server/pos-hardware-sale.d.ts +54 -0
- package/src/lib/server/pos-hardware-sale.js +369 -0
- package/src/lib/server/pos-hardware-sale.js.map +1 -0
- package/src/lib/server/pos-hardware-tax-return-source.d.ts +99 -0
- package/src/lib/server/pos-hardware-tax-return-source.js +462 -0
- package/src/lib/server/pos-hardware-tax-return-source.js.map +1 -0
- package/src/lib/server/pos-hardware-terms.d.ts +64 -0
- package/src/lib/server/pos-hardware-terms.js +154 -0
- package/src/lib/server/pos-hardware-terms.js.map +1 -0
- package/src/lib/server/pos-hardware-user-eraser.d.ts +3 -0
- package/src/lib/server/pos-hardware-user-eraser.js +31 -7
- package/src/lib/server/pos-hardware-user-eraser.js.map +1 -1
- package/src/lib/server/pos-hardware-webhook.d.ts +5 -0
- package/src/lib/server/pos-hardware-webhook.js +51 -6
- package/src/lib/server/pos-hardware-webhook.js.map +1 -1
- package/src/lib/server/pos-hardware.d.ts +74 -1
- package/src/lib/server/pos-hardware.js +175 -10
- package/src/lib/server/pos-hardware.js.map +1 -1
- package/src/lib/server/pos-kiosk.d.ts +2 -0
- package/src/lib/server/pos-kiosk.js +17 -12
- package/src/lib/server/pos-kiosk.js.map +1 -1
- package/src/lib/server/pos-offline-card-order.d.ts +64 -0
- package/src/lib/server/pos-offline-card-order.js +102 -0
- package/src/lib/server/pos-offline-card-order.js.map +1 -0
- package/src/lib/server/pos-offline-card-reconcile.d.ts +67 -1
- package/src/lib/server/pos-offline-card-reconcile.js +215 -18
- package/src/lib/server/pos-offline-card-reconcile.js.map +1 -1
- package/src/lib/server/pos-offline-sync.d.ts +39 -0
- package/src/lib/server/pos-offline-sync.js +190 -55
- package/src/lib/server/pos-offline-sync.js.map +1 -1
- package/src/lib/server/pos-ops-gate.d.ts +15 -4
- package/src/lib/server/pos-ops-gate.js +42 -9
- package/src/lib/server/pos-ops-gate.js.map +1 -1
- package/src/lib/server/pos-ops-routes.js +24 -0
- package/src/lib/server/pos-ops-routes.js.map +1 -1
- package/src/lib/server/pos-order-refund-ids.d.ts +28 -0
- package/src/lib/server/pos-order-refund-ids.js +31 -0
- package/src/lib/server/pos-order-refund-ids.js.map +1 -0
- package/src/lib/server/pos-order.js +52 -49
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.js +1 -1
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-reader-splash-admin.js +30 -32
- package/src/lib/server/pos-reader-splash-admin.js.map +1 -1
- package/src/lib/server/pos-reader-splash-images-route.d.ts +17 -0
- package/src/lib/server/pos-reader-splash-images-route.js +113 -0
- package/src/lib/server/pos-reader-splash-images-route.js.map +1 -0
- package/src/lib/server/pos-reader-splash-images.d.ts +51 -0
- package/src/lib/server/pos-reader-splash-images.js +123 -0
- package/src/lib/server/pos-reader-splash-images.js.map +1 -0
- package/src/lib/server/pos-reader-splash.d.ts +68 -1
- package/src/lib/server/pos-reader-splash.js +182 -11
- package/src/lib/server/pos-reader-splash.js.map +1 -1
- package/src/lib/server/pos-readers.d.ts +29 -0
- package/src/lib/server/pos-readers.js +134 -35
- package/src/lib/server/pos-readers.js.map +1 -1
- package/src/lib/server/pos-return.d.ts +10 -0
- package/src/lib/server/pos-return.js +26 -1
- package/src/lib/server/pos-return.js.map +1 -1
- package/src/lib/server/pos-sale.js +6 -1
- package/src/lib/server/pos-sale.js.map +1 -1
- package/src/lib/server/pos-shift.js +11 -0
- package/src/lib/server/pos-shift.js.map +1 -1
- package/src/lib/server/pos-staff-pin.js +25 -20
- package/src/lib/server/pos-staff-pin.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +14 -4
- package/src/lib/server/pos-terminal.js +34 -38
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/server/printers.d.ts +7 -3
- package/src/lib/server/printers.js +18 -12
- package/src/lib/server/printers.js.map +1 -1
- package/src/lib/server/product-drafts.d.ts +11 -1
- package/src/lib/server/product-drafts.js +12 -8
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product.d.ts +15 -1
- package/src/lib/server/product.js +16 -3
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/products-write.d.ts +26 -2
- package/src/lib/server/products-write.js +19 -7
- package/src/lib/server/products-write.js.map +1 -1
- package/src/lib/server/refund.js +34 -11
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reservation-availability-query.d.ts +8 -0
- package/src/lib/server/reservation-availability-query.js +11 -1
- package/src/lib/server/reservation-availability-query.js.map +1 -1
- package/src/lib/server/reservation-availability.d.ts +1 -1
- package/src/lib/server/reservation-availability.js +7 -2
- package/src/lib/server/reservation-availability.js.map +1 -1
- package/src/lib/server/reservation-guests.d.ts +32 -0
- package/src/lib/server/reservation-guests.js +285 -0
- package/src/lib/server/reservation-guests.js.map +1 -0
- package/src/lib/server/reservation-walk-in.d.ts +11 -1
- package/src/lib/server/reservation-walk-in.js +56 -12
- package/src/lib/server/reservation-walk-in.js.map +1 -1
- package/src/lib/server/reserve.js +18 -5
- package/src/lib/server/reserve.js.map +1 -1
- package/src/lib/server/returns.js +9 -6
- package/src/lib/server/returns.js.map +1 -1
- package/src/lib/server/reviews.d.ts +22 -2
- package/src/lib/server/reviews.js +88 -20
- package/src/lib/server/reviews.js.map +1 -1
- package/src/lib/server/shipping-connectors.js +10 -11
- package/src/lib/server/shipping-connectors.js.map +1 -1
- package/src/lib/server/site-page-resolver.js +20 -3
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server/store-day.d.ts +33 -0
- package/src/lib/server/store-day.js +46 -0
- package/src/lib/server/store-day.js.map +1 -0
- package/src/lib/server/store-setup-ai-writer.d.ts +2 -1
- package/src/lib/server/store-setup-ai-writer.js +5 -6
- package/src/lib/server/store-setup-ai-writer.js.map +1 -1
- package/src/lib/server/storefront-tax.d.ts +13 -0
- package/src/lib/server/storefront-tax.js +8 -1
- package/src/lib/server/storefront-tax.js.map +1 -1
- package/src/lib/server/tax-return-source.d.ts +32 -3
- package/src/lib/server/tax-return-source.js +99 -20
- package/src/lib/server/tax-return-source.js.map +1 -1
- package/src/lib/server.js +100 -2
- package/src/lib/server.js.map +1 -1
- package/src/lib/testing/fake-firestore.js +58 -16
- package/src/lib/testing/fake-firestore.js.map +1 -1
- package/src/lib/testing/pos-ops-memory-firestore.js +18 -4
- package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -1
- package/src/lib/testing/site-register-permissions.d.ts +29 -0
- package/src/lib/testing/site-register-permissions.js +38 -0
- package/src/lib/testing/site-register-permissions.js.map +1 -0
- package/src/lib/transfer/tracking.server.js +8 -5
- package/src/lib/transfer/tracking.server.js.map +1 -1
- package/src/lib/utils/add-to-cart.d.ts +2 -0
- package/src/lib/utils/add-to-cart.js +6 -3
- package/src/lib/utils/add-to-cart.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/commerce-reservations.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 * Reservations v1 (AGL-304): bookable units (cabins) with date-range\n * stays, seasonal pricing, deposits, and cancellation windows —\n * extending the appointment-slot bookings (AGL-159) rather than\n * replacing them. Dates are day-precision epoch-ms at UTC midnight\n * (`dayMs`); nights = checkout day − checkin day. Pure — the\n * reservation APIs and console own I/O.\n */\n\nimport type { StorefrontTaxMode } from './commerce-tax-decision'\n\nexport const DAY_MS = 24 * 60 * 60 * 1000\n\n/** Seasonal pricing window by month-day (year-agnostic, inclusive). */\nexport interface ResourceSeason {\n /** 'MM-DD' inclusive start, e.g. '06-01'. */\n from: string\n /** 'MM-DD' inclusive end; may wrap the year (e.g. '12-15'..'01-05'). */\n to: string\n /** Multiplier on the nightly rate, e.g. 1.5 for peak. */\n multiplier: number\n label?: string\n}\n\n/** `hosts/{hostId}/resources/{id}` doc. */\nexport interface HostResource {\n name: string\n description?: string\n /**\n * Sleeps N; display only. Never availability: how many guests one unit\n * takes says nothing about how many units there are (see `units`).\n */\n capacity?: number\n /**\n * How many identical units this one resource holds (AGL-4044): 12 RV\n * hookups, 30 tent sites, 4 matching cabins. Each night can take this many\n * stays at once. Absent means 1, which is every resource written before the\n * field existed, and one unit behaves exactly as a resource always has.\n * An integer from 1 to {@link MAX_RESOURCE_UNITS}; read it through\n * {@link resourceUnits}, never raw.\n */\n units?: number\n photoUrls?: string[]\n amenities?: string[]\n nightlyRateUsd: number\n /** Friday/Saturday nights multiply by this (default 1). */\n weekendMultiplier?: number\n seasons?: ResourceSeason[]\n minNights?: number\n /** Deposit due at reservation: percent of total (1-100). */\n depositPct?: number\n /** Free cancellation until this many hours before check-in. */\n cancellationHours?: number\n /** Manually blocked day ranges (maintenance etc.), dayMs pairs. */\n blocks?: Array<{ fromDayMs: number; toDayMs: number }>\n}\n\nexport type ReservationStatus =\n | 'pending'\n | 'confirmed'\n | 'checked_in'\n | 'checked_out'\n | 'cancelled'\n | 'no_show'\n\n/** `hosts/{hostId}/reservations/{id}` doc. */\nexport interface HostReservation {\n resourceId: string\n status: ReservationStatus\n /** UTC-midnight day of arrival. */\n checkInDayMs: number\n /** UTC-midnight day of departure (exclusive). */\n checkOutDayMs: number\n guestName?: string | null\n guestEmail?: string | null\n nights?: number\n totalCents?: number\n depositCents?: number\n /** Payments applied so far (deposit, folio settlements). */\n paidCents?: number\n /** POS folio lines charged to the stay (AGL-317). */\n folio?: Array<{\n orderId: string\n amountCents: number\n note?: string\n atMs: number\n }>\n checkoutSessionId?: string\n createdAtMs?: number\n /**\n * WHICH tax regime the paid deposit carried (AGL-1969), stamped at\n * confirmation from the same `storefrontTaxModeOf` derivation every order\n * door uses (AGL-2451).\n *\n * `manual` on a stay whose merchant had set a lodging rate\n * (`TaxSettings.lodging`), `none` where they had not — which is the default\n * and every store that has not opted in. Never `stripe-automatic` from this\n * path: Stripe Tax cannot compute occupancy tax without a lodging tax code\n * `reserve.ts` does not send, so the rate is always the merchant's own and\n * is never computed against Aglyn's registrations (AGL-1904).\n *\n * ABSENT is a fourth state and is not `none` — it means the reservation was\n * confirmed before this field existed. See `StorefrontTaxMode`.\n */\n taxMode?: StorefrontTaxMode\n /**\n * The lodging tax charged on top of `paidCents` (AGL-1969), from the\n * merchant's own rate. Absent, never zero, where none was charged.\n *\n * SEPARATE FROM `paidCents` on purpose: that field is the money applied to\n * the STAY and the console divides it by `totalCents` to show what is still\n * owed. Tax is not part of the stay's price and is not the merchant's\n * revenue.\n *\n * LIMITATION, stated rather than decided: this is the rate applied to what\n * was CHARGED, which on a deposit-taking resource is the deposit rather than\n * the stay. Whether a jurisdiction wants occupancy tax on the full stay at\n * booking, on the deposit, or on redemption is not a question this codebase\n * answers — see `reserve.ts` and the merchant copy on the Taxes card.\n */\n taxCents?: number\n}\n\n/** UTC midnight for an instant. */\nexport function toDayMs(atMs: number): number {\n return Math.floor(atMs / DAY_MS) * DAY_MS\n}\n\nfunction monthDay(dayMs: number): string {\n const date = new Date(dayMs)\n const month = String(date.getUTCMonth() + 1).padStart(2, '0')\n const day = String(date.getUTCDate()).padStart(2, '0')\n return `${month}-${day}`\n}\n\nfunction inSeason(dayKey: string, season: ResourceSeason): boolean {\n if (season.from <= season.to) {\n return dayKey >= season.from && dayKey <= season.to\n }\n // Wrapping season (e.g. 12-15 .. 01-05).\n return dayKey >= season.from || dayKey <= season.to\n}\n\n/** Per-night rate in cents for one specific night. */\nexport function nightlyRateCents(\n resource: Pick<\n HostResource,\n 'nightlyRateUsd' | 'weekendMultiplier' | 'seasons'\n >,\n dayMs: number,\n): number {\n let rate = resource.nightlyRateUsd * 100\n const weekday = new Date(dayMs).getUTCDay()\n if ((weekday === 5 || weekday === 6) && resource.weekendMultiplier) {\n rate *= resource.weekendMultiplier\n }\n const dayKey = monthDay(dayMs)\n for (const season of resource.seasons ?? []) {\n if (inSeason(dayKey, season)) {\n rate *= season.multiplier\n break\n }\n }\n return Math.round(rate)\n}\n\nexport interface ReservationQuote {\n nights: number\n subtotalCents: number\n depositCents: number\n totalCents: number\n /** Per-night breakdown for the quote UI. */\n nightlyCents: number[]\n problem?: string\n}\n\n/** Prices a stay; `problem` set (and zeros) when the range is invalid. */\nexport function computeReservationQuote(\n resource: HostResource,\n checkInDayMs: number,\n checkOutDayMs: number,\n): ReservationQuote {\n const empty: ReservationQuote = {\n nights: 0,\n subtotalCents: 0,\n depositCents: 0,\n totalCents: 0,\n nightlyCents: [],\n }\n const nights = Math.round((checkOutDayMs - checkInDayMs) / DAY_MS)\n if (!(nights > 0)) return { ...empty, problem: 'Choose at least one night' }\n if (resource.minNights && nights < resource.minNights) {\n return { ...empty, problem: `Minimum stay is ${resource.minNights} nights` }\n }\n const nightlyCents: number[] = []\n for (let day = checkInDayMs; day < checkOutDayMs; day += DAY_MS) {\n nightlyCents.push(nightlyRateCents(resource, day))\n }\n const subtotalCents = nightlyCents.reduce((sum, cents) => sum + cents, 0)\n const depositPct = Math.min(100, Math.max(0, resource.depositPct ?? 100))\n const depositCents = Math.round((subtotalCents * depositPct) / 100)\n return {\n nights,\n subtotalCents,\n depositCents,\n totalCents: subtotalCents,\n nightlyCents,\n }\n}\n\n/**\n * How long an unpaid `pending` reservation stands between the next guest and\n * the dates it named.\n *\n * A `pending` row is written before the Stripe session opens, and nothing ever\n * clears one: `process-abandoned.ts` sweeps `checkouts`, not `reservations`.\n * So the hold has to lapse by the clock rather than by a job, or one guest who\n * closed the tab at the payment screen takes those dates off the market\n * permanently.\n */\nexport const PENDING_RESERVATION_HOLD_MS = 30 * 60 * 1000\n\n/**\n * Does this reservation still stand between a guest and its dates?\n *\n * THE one answer, because four surfaces ask it — the booking door, the booking\n * transaction's re-read, the storefront availability endpoint behind the\n * date-picker, and the console's walk-in check — and they were not asking it\n * the same way. Only the booking door aged out a stale `pending`, so the\n * storefront painted dates unavailable that the booking door would have sold,\n * and the front desk was told a room was taken while it stood empty.\n *\n * A `pending` row carrying no `createdAtMs` releases rather than holds: an\n * unbounded hold on a row that cannot prove its own age is the failure this\n * lapse exists to prevent, and the booking door re-checks inside its\n * transaction before any money moves.\n */\nexport function reservationHoldsDates(\n reservation: Pick<HostReservation, 'status'> & { createdAtMs?: number },\n nowMs: number = Date.now(),\n): boolean {\n if (reservation.status === 'cancelled' || reservation.status === 'no_show') {\n return false\n }\n if (reservation.status !== 'pending') return true\n const createdAtMs = Number(reservation.createdAtMs ?? 0)\n return createdAtMs > 0 && nowMs - createdAtMs < PENDING_RESERVATION_HOLD_MS\n}\n\n/** The most identical units one resource can hold (AGL-4044). */\nexport const MAX_RESOURCE_UNITS = 500\n\n/**\n * How many units a resource holds: the stored `units` as a whole number from 1\n * to {@link MAX_RESOURCE_UNITS}, and 1 for anything else (absent, zero,\n * negative, not a number). Closing a resource is what `blocks` are for, so no\n * stored value can make a resource hold no units at all.\n */\nexport function resourceUnits(\n resource: Pick<HostResource, 'units'> | null | undefined,\n): number {\n const units = Math.floor(Number(resource?.units))\n if (!Number.isFinite(units) || units < 1) return 1\n return Math.min(MAX_RESOURCE_UNITS, units)\n}\n\n/** A reservation as an availability check reads it. */\nexport type HeldStay = Pick<\n HostReservation,\n 'checkInDayMs' | 'checkOutDayMs' | 'status'\n> & {\n createdAtMs?: number\n}\n\n/**\n * How many units are taken on each night from `fromDayMs` up to (not\n * including) `toDayMs`, one entry per night, counting only the stays that\n * still hold their dates ({@link reservationHoldsDates}). A stay takes a night\n * when it overlaps it, with the same `[checkIn, checkOut)` semantics as\n * {@link isRangeAvailable}: a stay that leaves the morning another arrives\n * does not take that night.\n */\nexport function unitsTakenByNight(\n reservations: HeldStay[],\n fromDayMs: number,\n toDayMs: number,\n nowMs: number = Date.now(),\n): number[] {\n const live = reservations.filter((reservation) =>\n reservationHoldsDates(reservation, nowMs),\n )\n const taken: number[] = []\n for (let night = fromDayMs; night < toDayMs; night += DAY_MS) {\n const nightEnd = Math.min(night + DAY_MS, toDayMs)\n let count = 0\n for (const reservation of live) {\n if (\n reservation.checkInDayMs < nightEnd &&\n reservation.checkOutDayMs > night\n ) {\n count++\n }\n }\n taken.push(count)\n }\n return taken\n}\n\n/** One night of a resource: how many of its units are still free. */\nexport interface ResourceNightUnits {\n dayMs: number\n unitsLeft: number\n units: number\n}\n\n/**\n * Units left on each of `nights` nights from `fromDayMs`: the resource's\n * units less the stays holding that night, and none on a blocked night,\n * because a block closes the whole resource.\n */\nexport function unitsLeftByNight(\n resource: Pick<HostResource, 'units' | 'blocks'>,\n reservations: HeldStay[],\n fromDayMs: number,\n nights: number,\n nowMs: number = Date.now(),\n): ResourceNightUnits[] {\n const units = resourceUnits(resource)\n const toDayMs = fromDayMs + Math.max(0, Math.floor(nights)) * DAY_MS\n return unitsTakenByNight(reservations, fromDayMs, toDayMs, nowMs).map(\n (taken, index) => {\n const dayMs = fromDayMs + index * DAY_MS\n const blocked = (resource.blocks ?? []).some(\n (block) => dayMs < block.toDayMs && dayMs + DAY_MS > block.fromDayMs,\n )\n return {\n dayMs,\n units,\n unitsLeft: blocked ? 0 : Math.max(0, units - taken),\n }\n },\n )\n}\n\n/**\n * Availability: a candidate range is free when, on EVERY night in it, fewer\n * live reservations overlap that night than the resource has units\n * (AGL-4044), and no manual block touches it. `[checkIn, checkOut)`\n * semantics, so back-to-back stays touch without conflict. A block closes the\n * whole resource, every unit at once.\n *\n * One unit (the default, and every resource written before `units`) takes\n * the original path unchanged: the range conflicts when it overlaps any live\n * reservation at all.\n *\n * `nowMs` is a parameter so the pending lapse is testable without freezing the\n * clock. A caller passing reservations without `createdAtMs` gets the same\n * answer as before for every status but `pending`.\n */\nexport function isRangeAvailable(\n resource: Pick<HostResource, 'blocks' | 'units'>,\n reservations: HeldStay[],\n checkInDayMs: number,\n checkOutDayMs: number,\n nowMs: number = Date.now(),\n): boolean {\n if (!(checkOutDayMs > checkInDayMs)) return false\n for (const block of resource.blocks ?? []) {\n if (checkInDayMs < block.toDayMs && checkOutDayMs > block.fromDayMs) {\n return false\n }\n }\n const units = resourceUnits(resource)\n if (units === 1) {\n for (const reservation of reservations) {\n if (!reservationHoldsDates(reservation, nowMs)) continue\n if (\n checkInDayMs < reservation.checkOutDayMs &&\n checkOutDayMs > reservation.checkInDayMs\n ) {\n return false\n }\n }\n return true\n }\n return unitsTakenByNight(\n reservations,\n checkInDayMs,\n checkOutDayMs,\n nowMs,\n ).every((taken) => taken < units)\n}\n\n/**\n * The widget's scarcity line starts at this many units left (AGL-4044):\n * \"Only 2 left\". Never on a one-unit resource, where every free night would\n * read \"Only 1 left\", and never on a night nothing is booked on.\n */\nexport const FEW_UNITS_LEFT = 3\n\n/**\n * The fewest units left across `[checkInDayMs, checkOutDayMs)` when that is\n * {@link FEW_UNITS_LEFT} or fewer and at least one, else null. `fewLeft`\n * lists only the scarce nights, as the availability endpoint sends them; a\n * night it leaves out has more than {@link FEW_UNITS_LEFT} free.\n */\nexport function fewestUnitsLeft(\n fewLeft: Array<{ dayMs: number; unitsLeft: number }> | null | undefined,\n checkInDayMs: number,\n checkOutDayMs: number,\n): number | null {\n let fewest: number | null = null\n for (const night of fewLeft ?? []) {\n if (night.dayMs < checkInDayMs || night.dayMs >= checkOutDayMs) continue\n if (!(night.unitsLeft >= 1) || night.unitsLeft > FEW_UNITS_LEFT) continue\n fewest = fewest === null ? night.unitsLeft : Math.min(fewest, night.unitsLeft)\n }\n return fewest\n}\n\n/** Free-cancellation check against the policy window. */\nexport function canCancelReservation(\n resource: Pick<HostResource, 'cancellationHours'>,\n reservation: Pick<HostReservation, 'checkInDayMs' | 'status'>,\n nowMs = Date.now(),\n): boolean {\n if (!['pending', 'confirmed'].includes(reservation.status)) return false\n const windowMs = (resource.cancellationHours ?? 0) * 60 * 60 * 1000\n return nowMs <= reservation.checkInDayMs - windowMs\n}\n"],"names":["DAY_MS","toDayMs","atMs","Math","floor","monthDay","dayMs","date","Date","month","String","getUTCMonth","padStart","day","getUTCDate","inSeason","dayKey","season","from","to","nightlyRateCents","resource","rate","nightlyRateUsd","weekday","getUTCDay","weekendMultiplier","seasons","multiplier","round","computeReservationQuote","checkInDayMs","checkOutDayMs","empty","nights","subtotalCents","depositCents","totalCents","nightlyCents","problem","minNights","push","reduce","sum","cents","depositPct","min","max","PENDING_RESERVATION_HOLD_MS","reservationHoldsDates","reservation","nowMs","now","status","createdAtMs","Number","MAX_RESOURCE_UNITS","resourceUnits","units","isFinite","unitsTakenByNight","reservations","fromDayMs","live","filter","taken","night","nightEnd","count","unitsLeftByNight","map","index","blocked","blocks","some","block","unitsLeft","isRangeAvailable","every","FEW_UNITS_LEFT","fewestUnitsLeft","fewLeft","fewest","canCancelReservation","includes","windowMs","cancellationHours"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;CAOC;AAID,OAAO,MAAMA,SAAS,KAAK,KAAK,KAAK,KAAI;AAgHzC,iCAAiC,GACjC,OAAO,SAASC,QAAQC,IAAY;IAClC,OAAOC,KAAKC,KAAK,CAACF,OAAOF,UAAUA;AACrC;AAEA,SAASK,SAASC,KAAa;IAC7B,MAAMC,OAAO,IAAIC,KAAKF;IACtB,MAAMG,QAAQC,OAAOH,KAAKI,WAAW,KAAK,GAAGC,QAAQ,CAAC,GAAG;IACzD,MAAMC,MAAMH,OAAOH,KAAKO,UAAU,IAAIF,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3C,KAAK4C,GAAG,EAAE;QAGA/B;IADlB,IAAI,CAAC;QAAC;QAAW;KAAY,CAAC+D,QAAQ,CAAClC,YAAYG,MAAM,GAAG,OAAO;IACnE,MAAMgC,WAAW,EAAChE,8BAAAA,SAASiE,iBAAiB,YAA1BjE,8BAA8B,KAAK,KAAK,KAAK;IAC/D,OAAO8B,SAASD,YAAYnB,YAAY,GAAGsD;AAC7C"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/commerce-reservations.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 * Reservations v1 (AGL-304): bookable units (cabins) with date-range\n * stays, seasonal pricing, deposits, and cancellation windows —\n * extending the appointment-slot bookings (AGL-159) rather than\n * replacing them. Dates are day-precision epoch-ms at UTC midnight\n * (`dayMs`); nights = checkout day − checkin day. Pure — the\n * reservation APIs and console own I/O.\n */\n\nimport type { StorefrontTaxMode } from './commerce-tax-decision'\n\nexport const DAY_MS = 24 * 60 * 60 * 1000\n\n/** Seasonal pricing window by month-day (year-agnostic, inclusive). */\nexport interface ResourceSeason {\n /** 'MM-DD' inclusive start, e.g. '06-01'. */\n from: string\n /** 'MM-DD' inclusive end; may wrap the year (e.g. '12-15'..'01-05'). */\n to: string\n /** Multiplier on the nightly rate, e.g. 1.5 for peak. */\n multiplier: number\n label?: string\n}\n\n/** `hosts/{hostId}/resources/{id}` doc. */\nexport interface HostResource {\n name: string\n description?: string\n /**\n * Sleeps N; display only. Never availability: how many guests one unit\n * takes says nothing about how many units there are (see `units`).\n */\n capacity?: number\n /**\n * How many identical units this one resource holds (AGL-4044): 12 RV\n * hookups, 30 tent sites, 4 matching cabins. Each night can take this many\n * stays at once. Absent means 1, which is every resource written before the\n * field existed, and one unit behaves exactly as a resource always has.\n * An integer from 1 to {@link MAX_RESOURCE_UNITS}; read it through\n * {@link resourceUnits}, never raw.\n */\n units?: number\n /**\n * When the booking widget's scarcity line (\"Only 2 left\") starts, for a\n * resource with several units (AGL-4044): it shows once this many units or\n * fewer are free on a night of the stay. Absent is\n * {@link FEW_UNITS_LEFT}, the line every several-unit resource has always\n * had; 0 never shows it. A whole number from 0 to\n * {@link MAX_RESOURCE_UNITS}; read it through {@link resourceFewLeftAt},\n * never raw.\n */\n fewLeftAt?: number\n /**\n * How a stay on this resource is checked in at the window (AGL-4043):\n * `false` or absent, one check-in (and wristband) per stay per day; `true`,\n * one per guest per day, from the stay's {@link HostReservation.guests}.\n * The store's quick control on the check-in screen can set every resource\n * at once (`settings/checkIn.stays`).\n */\n checkInPerGuest?: boolean\n photoUrls?: string[]\n amenities?: string[]\n nightlyRateUsd: number\n /** Friday/Saturday nights multiply by this (default 1). */\n weekendMultiplier?: number\n seasons?: ResourceSeason[]\n minNights?: number\n /** Deposit due at reservation: percent of total (1-100). */\n depositPct?: number\n /** Free cancellation until this many hours before check-in. */\n cancellationHours?: number\n /** Manually blocked day ranges (maintenance etc.), dayMs pairs. */\n blocks?: Array<{ fromDayMs: number; toDayMs: number }>\n}\n\nexport type ReservationStatus =\n | 'pending'\n | 'confirmed'\n | 'checked_in'\n | 'checked_out'\n | 'cancelled'\n | 'no_show'\n\n/** `hosts/{hostId}/reservations/{id}` doc. */\nexport interface HostReservation {\n resourceId: string\n status: ReservationStatus\n /** UTC-midnight day of arrival. */\n checkInDayMs: number\n /** UTC-midnight day of departure (exclusive). */\n checkOutDayMs: number\n guestName?: string | null\n guestEmail?: string | null\n /**\n * How many guests the stay is for (AGL-4043), 1 up to what the resource\n * sleeps ({@link resourceGuestCeiling}); absent on a stay booked before the\n * field existed, or without an answer, which reads as 1. Checking in one\n * guest at a time asks it.\n */\n guests?: number\n /** When staff last changed {@link guests} after booking, and who (AGL-4043). */\n guestsChangedAtMs?: number\n guestsChangedBy?: string\n nights?: number\n totalCents?: number\n depositCents?: number\n /** Payments applied so far (deposit, folio settlements). */\n paidCents?: number\n /** POS folio lines charged to the stay (AGL-317). */\n folio?: Array<{\n orderId: string\n amountCents: number\n note?: string\n atMs: number\n }>\n checkoutSessionId?: string\n createdAtMs?: number\n /**\n * WHICH tax regime the paid deposit carried (AGL-1969), stamped at\n * confirmation from the same `storefrontTaxModeOf` derivation every order\n * door uses (AGL-2451).\n *\n * `manual` on a stay whose merchant had set a lodging rate\n * (`TaxSettings.lodging`), `none` where they had not — which is the default\n * and every store that has not opted in. Never `stripe-automatic` from this\n * path: Stripe Tax cannot compute occupancy tax without a lodging tax code\n * `reserve.ts` does not send, so the rate is always the merchant's own and\n * is never computed against Aglyn's registrations (AGL-1904).\n *\n * ABSENT is a fourth state and is not `none` — it means the reservation was\n * confirmed before this field existed. See `StorefrontTaxMode`.\n */\n taxMode?: StorefrontTaxMode\n /**\n * The lodging tax charged on top of `paidCents` (AGL-1969), from the\n * merchant's own rate. Absent, never zero, where none was charged.\n *\n * SEPARATE FROM `paidCents` on purpose: that field is the money applied to\n * the STAY and the console divides it by `totalCents` to show what is still\n * owed. Tax is not part of the stay's price and is not the merchant's\n * revenue.\n *\n * LIMITATION, stated rather than decided: this is the rate applied to what\n * was CHARGED, which on a deposit-taking resource is the deposit rather than\n * the stay. Whether a jurisdiction wants occupancy tax on the full stay at\n * booking, on the deposit, or on redemption is not a question this codebase\n * answers — see `reserve.ts` and the merchant copy on the Taxes card.\n */\n taxCents?: number\n}\n\n/** UTC midnight for an instant. */\nexport function toDayMs(atMs: number): number {\n return Math.floor(atMs / DAY_MS) * DAY_MS\n}\n\nfunction monthDay(dayMs: number): string {\n const date = new Date(dayMs)\n const month = String(date.getUTCMonth() + 1).padStart(2, '0')\n const day = String(date.getUTCDate()).padStart(2, '0')\n return `${month}-${day}`\n}\n\nfunction inSeason(dayKey: string, season: ResourceSeason): boolean {\n if (season.from <= season.to) {\n return dayKey >= season.from && dayKey <= season.to\n }\n // Wrapping season (e.g. 12-15 .. 01-05).\n return dayKey >= season.from || dayKey <= season.to\n}\n\n/** Per-night rate in cents for one specific night. */\nexport function nightlyRateCents(\n resource: Pick<\n HostResource,\n 'nightlyRateUsd' | 'weekendMultiplier' | 'seasons'\n >,\n dayMs: number,\n): number {\n let rate = resource.nightlyRateUsd * 100\n const weekday = new Date(dayMs).getUTCDay()\n if ((weekday === 5 || weekday === 6) && resource.weekendMultiplier) {\n rate *= resource.weekendMultiplier\n }\n const dayKey = monthDay(dayMs)\n for (const season of resource.seasons ?? []) {\n if (inSeason(dayKey, season)) {\n rate *= season.multiplier\n break\n }\n }\n return Math.round(rate)\n}\n\nexport interface ReservationQuote {\n nights: number\n subtotalCents: number\n depositCents: number\n totalCents: number\n /** Per-night breakdown for the quote UI. */\n nightlyCents: number[]\n problem?: string\n}\n\n/** Prices a stay; `problem` set (and zeros) when the range is invalid. */\nexport function computeReservationQuote(\n resource: HostResource,\n checkInDayMs: number,\n checkOutDayMs: number,\n): ReservationQuote {\n const empty: ReservationQuote = {\n nights: 0,\n subtotalCents: 0,\n depositCents: 0,\n totalCents: 0,\n nightlyCents: [],\n }\n const nights = Math.round((checkOutDayMs - checkInDayMs) / DAY_MS)\n if (!(nights > 0)) return { ...empty, problem: 'Choose at least one night' }\n if (resource.minNights && nights < resource.minNights) {\n return { ...empty, problem: `Minimum stay is ${resource.minNights} nights` }\n }\n const nightlyCents: number[] = []\n for (let day = checkInDayMs; day < checkOutDayMs; day += DAY_MS) {\n nightlyCents.push(nightlyRateCents(resource, day))\n }\n const subtotalCents = nightlyCents.reduce((sum, cents) => sum + cents, 0)\n const depositPct = Math.min(100, Math.max(0, resource.depositPct ?? 100))\n const depositCents = Math.round((subtotalCents * depositPct) / 100)\n return {\n nights,\n subtotalCents,\n depositCents,\n totalCents: subtotalCents,\n nightlyCents,\n }\n}\n\n/**\n * How long an unpaid `pending` reservation stands between the next guest and\n * the dates it named.\n *\n * A `pending` row is written before the Stripe session opens, and nothing ever\n * clears one: `process-abandoned.ts` sweeps `checkouts`, not `reservations`.\n * So the hold has to lapse by the clock rather than by a job, or one guest who\n * closed the tab at the payment screen takes those dates off the market\n * permanently.\n */\nexport const PENDING_RESERVATION_HOLD_MS = 30 * 60 * 1000\n\n/**\n * Does this reservation still stand between a guest and its dates?\n *\n * THE one answer, because four surfaces ask it — the booking door, the booking\n * transaction's re-read, the storefront availability endpoint behind the\n * date-picker, and the console's walk-in check — and they were not asking it\n * the same way. Only the booking door aged out a stale `pending`, so the\n * storefront painted dates unavailable that the booking door would have sold,\n * and the front desk was told a room was taken while it stood empty.\n *\n * A `pending` row carrying no `createdAtMs` releases rather than holds: an\n * unbounded hold on a row that cannot prove its own age is the failure this\n * lapse exists to prevent, and the booking door re-checks inside its\n * transaction before any money moves.\n */\nexport function reservationHoldsDates(\n reservation: Pick<HostReservation, 'status'> & { createdAtMs?: number },\n nowMs: number = Date.now(),\n): boolean {\n if (reservation.status === 'cancelled' || reservation.status === 'no_show') {\n return false\n }\n if (reservation.status !== 'pending') return true\n const createdAtMs = Number(reservation.createdAtMs ?? 0)\n return createdAtMs > 0 && nowMs - createdAtMs < PENDING_RESERVATION_HOLD_MS\n}\n\n/** The most identical units one resource can hold (AGL-4044). */\nexport const MAX_RESOURCE_UNITS = 500\n\n/**\n * How many units a resource holds: the stored `units` as a whole number from 1\n * to {@link MAX_RESOURCE_UNITS}, and 1 for anything else (absent, zero,\n * negative, not a number). Closing a resource is what `blocks` are for, so no\n * stored value can make a resource hold no units at all.\n */\nexport function resourceUnits(\n resource: Pick<HostResource, 'units'> | null | undefined,\n): number {\n const units = Math.floor(Number(resource?.units))\n if (!Number.isFinite(units) || units < 1) return 1\n return Math.min(MAX_RESOURCE_UNITS, units)\n}\n\n/** A reservation as an availability check reads it. */\nexport type HeldStay = Pick<\n HostReservation,\n 'checkInDayMs' | 'checkOutDayMs' | 'status'\n> & {\n createdAtMs?: number\n}\n\n/**\n * How many units are taken on each night from `fromDayMs` up to (not\n * including) `toDayMs`, one entry per night, counting only the stays that\n * still hold their dates ({@link reservationHoldsDates}). A stay takes a night\n * when it overlaps it, with the same `[checkIn, checkOut)` semantics as\n * {@link isRangeAvailable}: a stay that leaves the morning another arrives\n * does not take that night.\n */\nexport function unitsTakenByNight(\n reservations: HeldStay[],\n fromDayMs: number,\n toDayMs: number,\n nowMs: number = Date.now(),\n): number[] {\n const live = reservations.filter((reservation) =>\n reservationHoldsDates(reservation, nowMs),\n )\n const taken: number[] = []\n for (let night = fromDayMs; night < toDayMs; night += DAY_MS) {\n const nightEnd = Math.min(night + DAY_MS, toDayMs)\n let count = 0\n for (const reservation of live) {\n if (\n reservation.checkInDayMs < nightEnd &&\n reservation.checkOutDayMs > night\n ) {\n count++\n }\n }\n taken.push(count)\n }\n return taken\n}\n\n/** One night of a resource: how many of its units are still free. */\nexport interface ResourceNightUnits {\n dayMs: number\n unitsLeft: number\n units: number\n}\n\n/**\n * Units left on each of `nights` nights from `fromDayMs`: the resource's\n * units less the stays holding that night, and none on a blocked night,\n * because a block closes the whole resource.\n */\nexport function unitsLeftByNight(\n resource: Pick<HostResource, 'units' | 'blocks'>,\n reservations: HeldStay[],\n fromDayMs: number,\n nights: number,\n nowMs: number = Date.now(),\n): ResourceNightUnits[] {\n const units = resourceUnits(resource)\n const toDayMs = fromDayMs + Math.max(0, Math.floor(nights)) * DAY_MS\n return unitsTakenByNight(reservations, fromDayMs, toDayMs, nowMs).map(\n (taken, index) => {\n const dayMs = fromDayMs + index * DAY_MS\n const blocked = (resource.blocks ?? []).some(\n (block) => dayMs < block.toDayMs && dayMs + DAY_MS > block.fromDayMs,\n )\n return {\n dayMs,\n units,\n unitsLeft: blocked ? 0 : Math.max(0, units - taken),\n }\n },\n )\n}\n\n/**\n * Availability: a candidate range is free when, on EVERY night in it, fewer\n * live reservations overlap that night than the resource has units\n * (AGL-4044), and no manual block touches it. `[checkIn, checkOut)`\n * semantics, so back-to-back stays touch without conflict. A block closes the\n * whole resource, every unit at once.\n *\n * One unit (the default, and every resource written before `units`) takes\n * the original path unchanged: the range conflicts when it overlaps any live\n * reservation at all.\n *\n * `nowMs` is a parameter so the pending lapse is testable without freezing the\n * clock. A caller passing reservations without `createdAtMs` gets the same\n * answer as before for every status but `pending`.\n */\nexport function isRangeAvailable(\n resource: Pick<HostResource, 'blocks' | 'units'>,\n reservations: HeldStay[],\n checkInDayMs: number,\n checkOutDayMs: number,\n nowMs: number = Date.now(),\n): boolean {\n if (!(checkOutDayMs > checkInDayMs)) return false\n for (const block of resource.blocks ?? []) {\n if (checkInDayMs < block.toDayMs && checkOutDayMs > block.fromDayMs) {\n return false\n }\n }\n const units = resourceUnits(resource)\n if (units === 1) {\n for (const reservation of reservations) {\n if (!reservationHoldsDates(reservation, nowMs)) continue\n if (\n checkInDayMs < reservation.checkOutDayMs &&\n checkOutDayMs > reservation.checkInDayMs\n ) {\n return false\n }\n }\n return true\n }\n return unitsTakenByNight(\n reservations,\n checkInDayMs,\n checkOutDayMs,\n nowMs,\n ).every((taken) => taken < units)\n}\n\n/**\n * The widget's scarcity line starts at this many units left (AGL-4044):\n * \"Only 2 left\". Never on a one-unit resource, where every free night would\n * read \"Only 1 left\", and never on a night nothing is booked on.\n * A resource may set its own threshold, {@link HostResource.fewLeftAt}.\n */\nexport const FEW_UNITS_LEFT = 3\n\n/**\n * When a resource's scarcity line starts: its own `fewLeftAt` as a whole\n * number from 0 (never) to {@link MAX_RESOURCE_UNITS}, and\n * {@link FEW_UNITS_LEFT} for anything else (absent, negative, not a number),\n * so a resource saved before the setting existed reads exactly as it did.\n */\nexport function resourceFewLeftAt(\n resource: Pick<HostResource, 'fewLeftAt'> | null | undefined,\n): number {\n const raw = resource?.fewLeftAt\n if (raw === undefined || raw === null || (raw as unknown) === '') return FEW_UNITS_LEFT\n const at = Math.floor(Number(raw))\n if (!Number.isFinite(at) || at < 0) return FEW_UNITS_LEFT\n return Math.min(MAX_RESOURCE_UNITS, at)\n}\n\n/**\n * The fewest units left across `[checkInDayMs, checkOutDayMs)` when that is\n * `fewLeftAt` or fewer and at least one, else null. `fewLeft` lists only the\n * scarce nights, as the availability endpoint sends them; a night it leaves\n * out has more than the resource's threshold free. `fewLeftAt` is the\n * resource's threshold ({@link resourceFewLeftAt}); 0 never shows the line.\n */\nexport function fewestUnitsLeft(\n fewLeft: Array<{ dayMs: number; unitsLeft: number }> | null | undefined,\n checkInDayMs: number,\n checkOutDayMs: number,\n fewLeftAt: number = FEW_UNITS_LEFT,\n): number | null {\n let fewest: number | null = null\n for (const night of fewLeft ?? []) {\n if (night.dayMs < checkInDayMs || night.dayMs >= checkOutDayMs) continue\n if (!(night.unitsLeft >= 1) || night.unitsLeft > fewLeftAt) continue\n fewest = fewest === null ? night.unitsLeft : Math.min(fewest, night.unitsLeft)\n }\n return fewest\n}\n\n/** The most guests one stay may name when its resource says nothing of how many it sleeps. */\nexport const MAX_RESERVATION_GUESTS = 50\n\n/** Where staff change a stay's guest count after it is booked (AGL-4043): `{ hostId, reservationId, guests }`. */\nexport const RESERVATION_GUESTS_ROUTE = '/api/commerce/reservations/guests'\n\n/**\n * The most guests a stay on this resource may name: what one unit sleeps\n * (`capacity`), else {@link MAX_RESERVATION_GUESTS}.\n */\nexport function resourceGuestCeiling(resource: Pick<HostResource, 'capacity'> | null | undefined): number {\n const sleeps = Math.floor(Number(resource?.capacity))\n return Number.isFinite(sleeps) && sleeps >= 1 ? Math.min(sleeps, MAX_RESERVATION_GUESTS) : MAX_RESERVATION_GUESTS\n}\n\n/** How many guests a stay is for: its `guests` as a whole number of at least 1, else 1. */\nexport function reservationGuests(reservation: Pick<HostReservation, 'guests'> | null | undefined): number {\n const guests = Math.floor(Number(reservation?.guests))\n return Number.isFinite(guests) && guests >= 1 ? Math.min(guests, MAX_RESERVATION_GUESTS) : 1\n}\n\n/**\n * Why a guest count cannot be booked on a resource, or null. Absent (or\n * empty) is fine: the stay is for one guest as far as check-in is concerned.\n */\nexport function reservationGuestsProblem(\n guests: unknown,\n resource: Pick<HostResource, 'capacity'> | null | undefined,\n): string | null {\n if (guests === undefined || guests === null || guests === '') return null\n const count = Number(guests)\n const ceiling = resourceGuestCeiling(resource)\n if (!Number.isInteger(count) || count < 1 || count > ceiling) {\n return ceiling === 1 ? 'This stay sleeps 1 guest' : `Guests must be a whole number from 1 to ${ceiling}`\n }\n return null\n}\n\n/**\n * How the store checks stays in (AGL-4043), the quick control on the\n * check-in screen: `resource` follows each resource's own setting\n * ({@link HostResource.checkInPerGuest}); `stay` and `guest` set every\n * resource at once. Stored at `hosts/{hostId}/settings/checkIn.stays`.\n */\nexport type StayCheckInMode = 'resource' | 'stay' | 'guest'\n\nexport const STAY_CHECK_IN_MODES: readonly StayCheckInMode[] = ['resource', 'stay', 'guest']\n\n/** A stored mode made safe: anything unknown follows each resource. */\nexport function readStayCheckInMode(value: unknown): StayCheckInMode {\n return value === 'stay' || value === 'guest' ? value : 'resource'\n}\n\n/** Whether a stay on this resource is checked in one guest at a time, under the store's mode. */\nexport function stayChecksInPerGuest(\n resource: Pick<HostResource, 'checkInPerGuest'> | null | undefined,\n mode: StayCheckInMode,\n): boolean {\n if (mode === 'guest') return true\n if (mode === 'stay') return false\n return resource?.checkInPerGuest === true\n}\n\n/** Free-cancellation check against the policy window. */\nexport function canCancelReservation(\n resource: Pick<HostResource, 'cancellationHours'>,\n reservation: Pick<HostReservation, 'checkInDayMs' | 'status'>,\n nowMs = Date.now(),\n): boolean {\n if (!['pending', 'confirmed'].includes(reservation.status)) return false\n const windowMs = (resource.cancellationHours ?? 0) * 60 * 60 * 1000\n return nowMs <= reservation.checkInDayMs - windowMs\n}\n"],"names":["DAY_MS","toDayMs","atMs","Math","floor","monthDay","dayMs","date","Date","month","String","getUTCMonth","padStart","day","getUTCDate","inSeason","dayKey","season","from","to","nightlyRateCents","resource","rate","nightlyRateUsd","weekday","getUTCDay","weekendMultiplier","seasons","multiplier","round","computeReservationQuote","checkInDayMs","checkOutDayMs","empty","nights","subtotalCents","depositCents","totalCents","nightlyCents","problem","minNights","push","reduce","sum","cents","depositPct","min","max","PENDING_RESERVATION_HOLD_MS","reservationHoldsDates","reservation","nowMs","now","status","createdAtMs","Number","MAX_RESOURCE_UNITS","resourceUnits","units","isFinite","unitsTakenByNight","reservations","fromDayMs","live","filter","taken","night","nightEnd","count","unitsLeftByNight","map","index","blocked","blocks","some","block","unitsLeft","isRangeAvailable","every","FEW_UNITS_LEFT","resourceFewLeftAt","raw","fewLeftAt","undefined","at","fewestUnitsLeft","fewLeft","fewest","MAX_RESERVATION_GUESTS","RESERVATION_GUESTS_ROUTE","resourceGuestCeiling","sleeps","capacity","reservationGuests","guests","reservationGuestsProblem","ceiling","isInteger","STAY_CHECK_IN_MODES","readStayCheckInMode","value","stayChecksInPerGuest","mode","checkInPerGuest","canCancelReservation","includes","windowMs","cancellationHours"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;CAOC;AAID,OAAO,MAAMA,SAAS,KAAK,KAAK,KAAK,KAAI;AA4IzC,iCAAiC,GACjC,OAAO,SAASC,QAAQC,IAAY;IAClC,OAAOC,KAAKC,KAAK,CAACF,OAAOF,UAAUA;AACrC;AAEA,SAASK,SAASC,KAAa;IAC7B,MAAMC,OAAO,IAAIC,KAAKF;IACtB,MAAMG,QAAQC,OAAOH,KAAKI,WAAW,KAAK,GAAGC,QAAQ,CAAC,GAAG;IACzD,MAAMC,MAAMH,OAAOH,KAAKO,UAAU,IAAIF,QAAQ,CAAC,GAAG;IAClD,OAAO,GAAGH,MAAM,CAAC,EAAEI,KAAK;AAC1B;AAEA,SAASE,SAASC,MAAc,EAAEC,MAAsB;IACtD,IAAIA,OAAOC,IAAI,IAAID,OAAOE,EAAE,EAAE;QAC5B,OAAOH,UAAUC,OAAOC,IAAI,IAAIF,UA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AAS,OAAO;IAC7B,IAAIA,SAAS,QAAQ,OAAO;IAC5B,OAAOjF,CAAAA,4BAAAA,SAAUkF,eAAe,MAAK;AACvC;AAEA,uDAAuD,GACvD,OAAO,SAASC,qBACdnF,QAAiD,EACjD6B,WAA6D,EAC7DC,QAAQ3C,KAAK4C,GAAG,EAAE;QAGA/B;IADlB,IAAI,CAAC;QAAC;QAAW;KAAY,CAACoF,QAAQ,CAACvD,YAAYG,MAAM,GAAG,OAAO;IACnE,MAAMqD,WAAW,EAACrF,8BAAAA,SAASsF,iBAAiB,YAA1BtF,8BAA8B,KAAK,KAAK,KAAK;IAC/D,OAAO8B,SAASD,YAAYnB,YAAY,GAAG2E;AAC7C"}
|
|
@@ -76,6 +76,11 @@ export interface ProductVariant {
|
|
|
76
76
|
* product's own setting; absent follows the product.
|
|
77
77
|
*/
|
|
78
78
|
checkIn?: ProductCheckIn;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the self-service kiosk offers this variant (AGL-4038), within the
|
|
81
|
+
* product's own choice: `false` leaves it out; absent follows the product.
|
|
82
|
+
*/
|
|
83
|
+
offerOnKiosk?: boolean;
|
|
79
84
|
}
|
|
80
85
|
/** A product's packed size and customs facts (AGL-3612). */
|
|
81
86
|
export interface ProductShippingFacts {
|
|
@@ -169,6 +174,13 @@ export interface HostProduct {
|
|
|
169
174
|
name: string;
|
|
170
175
|
/** Host-unique URL segment for /products/{slug}. */
|
|
171
176
|
slug: string;
|
|
177
|
+
/**
|
|
178
|
+
* A SAMPLE a guided start made for the merchant to replace (AGL-4065): the
|
|
179
|
+
* store's brief named kinds of product and no product. Products shows it
|
|
180
|
+
* as a sample; the storefront never reads it; the merchant's save clears
|
|
181
|
+
* it (`productSaveFields`).
|
|
182
|
+
*/
|
|
183
|
+
sample?: boolean;
|
|
172
184
|
description?: string;
|
|
173
185
|
type: ProductType;
|
|
174
186
|
status: ProductStatus;
|
|
@@ -263,6 +275,31 @@ export interface HostProduct {
|
|
|
263
275
|
* {@link productSellsOnline}, never as a truthy field.
|
|
264
276
|
*/
|
|
265
277
|
sellOnline?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* What the site's review surfaces do with the reviews of a product sold in
|
|
280
|
+
* person only (`sellOnline: false`, AGL-4060): `show` (or absent) lists
|
|
281
|
+
* them, marked "Sold in store" and never linked; `hide` keeps them off
|
|
282
|
+
* every online surface — the store-wide reviews list and its average. A
|
|
283
|
+
* product sold online ignores it. Read it through
|
|
284
|
+
* {@link productReviewsOnline}.
|
|
285
|
+
*/
|
|
286
|
+
inStoreReviews?: 'show' | 'hide';
|
|
287
|
+
/**
|
|
288
|
+
* Whether the self-service kiosk offers the product (AGL-4038): `false`
|
|
289
|
+
* leaves it off the kiosk's grid and refuses it in a kiosk's cart, while
|
|
290
|
+
* the register, the POS apps and the site sell it as before. Absent reads
|
|
291
|
+
* as `true`, so every product stored before the choice is offered as it
|
|
292
|
+
* was; read it through `productOfferedOnKiosk` (`commerce-kiosk-offer.ts`). A variant's own
|
|
293
|
+
* `offerOnKiosk` narrows it further.
|
|
294
|
+
*/
|
|
295
|
+
offerOnKiosk?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* The point of sale hardware item this product IS (AGL-4038), by its id in
|
|
298
|
+
* the hardware catalog (`POS_HARDWARE_SKUS`): a sale of it on the
|
|
299
|
+
* platform's own store becomes a hardware order for the buyer's workspace.
|
|
300
|
+
* Read only on that store; on any other store it means nothing.
|
|
301
|
+
*/
|
|
302
|
+
hardwareSku?: string;
|
|
266
303
|
/**
|
|
267
304
|
* A pass, a camping spot, parking: each item sold is somebody to check in
|
|
268
305
|
* at the window on the day it was bought, `headcount` people per item
|
|
@@ -741,6 +778,12 @@ export declare function smartCollectionMatches(product: MembershipProduct, colle
|
|
|
741
778
|
export declare function productSellsOnline(product: {
|
|
742
779
|
sellOnline?: unknown;
|
|
743
780
|
} | null | undefined): boolean;
|
|
781
|
+
/** Whether a product is a sample a guided start made for the merchant to replace (AGL-4065). */
|
|
782
|
+
export declare function productIsSample(product: {
|
|
783
|
+
sample?: unknown;
|
|
784
|
+
} | null | undefined): boolean;
|
|
785
|
+
/** What Products says beside a sample (AGL-4065). */
|
|
786
|
+
export declare const PRODUCT_SAMPLE_NOTE = "A sample made from the kinds of product your site\u2019s brief named. Replace it with your own product: saving your changes makes it yours.";
|
|
744
787
|
/**
|
|
745
788
|
* Whether a shopper online may see or buy a product (AGL-4060): live, active
|
|
746
789
|
* and sold online. Every online surface (the product page, grids, search,
|
|
@@ -752,6 +795,29 @@ export declare function productListedOnline(product: {
|
|
|
752
795
|
status?: unknown;
|
|
753
796
|
sellOnline?: unknown;
|
|
754
797
|
} | null | undefined): boolean;
|
|
798
|
+
/** The choices a product sold in person only has for its reviews on the site (AGL-4060). */
|
|
799
|
+
export declare const IN_STORE_REVIEWS_CHOICES: readonly ["show", "hide"];
|
|
800
|
+
/**
|
|
801
|
+
* How a product's reviews appear on the site's online review surfaces
|
|
802
|
+
* (AGL-4060), or `null` when there is no product to say (deleted, a draft):
|
|
803
|
+
*
|
|
804
|
+
* - `listed`: sold online, so named and linked to its page;
|
|
805
|
+
* - `sold-in-store`: sold in person only, and the store shows its reviews —
|
|
806
|
+
* the default — named, marked "Sold in store", never linked (there is no
|
|
807
|
+
* page to link to);
|
|
808
|
+
* - `hidden`: sold in person only, and the store chose to keep its reviews
|
|
809
|
+
* off the site: in no list and no average.
|
|
810
|
+
*
|
|
811
|
+
* The store's choice is honored whatever the product's status, so a hidden
|
|
812
|
+
* product archived later stays hidden.
|
|
813
|
+
*/
|
|
814
|
+
export type ProductReviewsOnline = 'listed' | 'sold-in-store' | 'hidden';
|
|
815
|
+
export declare function productReviewsOnline(product: {
|
|
816
|
+
deletedAt?: unknown;
|
|
817
|
+
status?: unknown;
|
|
818
|
+
sellOnline?: unknown;
|
|
819
|
+
inStoreReviews?: unknown;
|
|
820
|
+
} | null | undefined): ProductReviewsOnline | null;
|
|
755
821
|
/**
|
|
756
822
|
* Smart-collection membership: draft/archived/deleted products never
|
|
757
823
|
* match; manual collections answer from productIds.
|
|
@@ -767,6 +767,10 @@ export function smartCollectionMatches(product, collection) {
|
|
|
767
767
|
*/ export function productSellsOnline(product) {
|
|
768
768
|
return (product == null ? void 0 : product.sellOnline) !== false;
|
|
769
769
|
}
|
|
770
|
+
/** Whether a product is a sample a guided start made for the merchant to replace (AGL-4065). */ export function productIsSample(product) {
|
|
771
|
+
return (product == null ? void 0 : product.sample) === true;
|
|
772
|
+
}
|
|
773
|
+
/** What Products says beside a sample (AGL-4065). */ export const PRODUCT_SAMPLE_NOTE = 'A sample made from the kinds of product your site’s brief named. Replace it with your own product: saving your changes makes it yours.';
|
|
770
774
|
/**
|
|
771
775
|
* Whether a shopper online may see or buy a product (AGL-4060): live, active
|
|
772
776
|
* and sold online. Every online surface (the product page, grids, search,
|
|
@@ -775,6 +779,17 @@ export function smartCollectionMatches(product, collection) {
|
|
|
775
779
|
*/ export function productListedOnline(product) {
|
|
776
780
|
return Boolean(product) && !(product == null ? void 0 : product.deletedAt) && (product == null ? void 0 : product.status) === 'active' && productSellsOnline(product);
|
|
777
781
|
}
|
|
782
|
+
/** The choices a product sold in person only has for its reviews on the site (AGL-4060). */ export const IN_STORE_REVIEWS_CHOICES = [
|
|
783
|
+
'show',
|
|
784
|
+
'hide'
|
|
785
|
+
];
|
|
786
|
+
export function productReviewsOnline(product) {
|
|
787
|
+
if (!product) return null;
|
|
788
|
+
if (!productSellsOnline(product) && product.inStoreReviews === 'hide') return 'hidden';
|
|
789
|
+
if (productListedOnline(product)) return 'listed';
|
|
790
|
+
if (!product.deletedAt && product.status === 'active' && !productSellsOnline(product)) return 'sold-in-store';
|
|
791
|
+
return null;
|
|
792
|
+
}
|
|
778
793
|
/**
|
|
779
794
|
* Smart-collection membership: draft/archived/deleted products never
|
|
780
795
|
* match; manual collections answer from productIds.
|