@final-commerce/command-frame 0.7.0-staging.4 → 0.8.0-online.1
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/dist/CommonTypes.d.ts +1 -11
- package/dist/actions/start-checkout/action.d.ts +6 -0
- package/dist/actions/start-checkout/action.js +8 -0
- package/dist/actions/start-checkout/mock.d.ts +16 -0
- package/dist/actions/start-checkout/mock.js +80 -0
- package/dist/actions/start-checkout/types.d.ts +81 -0
- package/dist/actions/start-checkout/types.js +10 -0
- package/dist/demo/database.d.ts +1 -12
- package/dist/demo/database.js +0 -127
- package/dist/index.d.ts +4 -16
- package/dist/index.js +3 -15
- package/dist/projects/render/mocks.js +2 -14
- package/dist/projects/render/types.d.ts +7 -8
- package/dist/pubsub/topics/checkout/checkout-started/types.d.ts +26 -0
- package/dist/pubsub/topics/checkout/index.d.ts +7 -0
- package/dist/pubsub/topics/checkout/index.js +28 -0
- package/dist/pubsub/topics/checkout/payment-completed/types.d.ts +19 -0
- package/dist/pubsub/topics/checkout/payment-failed/types.d.ts +20 -0
- package/dist/pubsub/topics/checkout/types.d.ts +12 -0
- package/dist/pubsub/topics/checkout/types.js +8 -0
- package/dist/pubsub/topics/index.d.ts +17 -17
- package/dist/pubsub/topics/index.js +17 -17
- package/dist/pubsub/topics/types.d.ts +8 -2
- package/package.json +2 -2
- package/dist/actions/add-booking-to-cart/action.d.ts +0 -6
- package/dist/actions/add-booking-to-cart/action.js +0 -8
- package/dist/actions/add-booking-to-cart/mock.d.ts +0 -2
- package/dist/actions/add-booking-to-cart/mock.js +0 -44
- package/dist/actions/add-booking-to-cart/types.d.ts +0 -23
- package/dist/actions/cancel-booking/action.d.ts +0 -6
- package/dist/actions/cancel-booking/action.js +0 -8
- package/dist/actions/cancel-booking/mock.d.ts +0 -2
- package/dist/actions/cancel-booking/mock.js +0 -10
- package/dist/actions/cancel-booking/types.d.ts +0 -10
- package/dist/actions/get-booking-availability/action.d.ts +0 -6
- package/dist/actions/get-booking-availability/action.js +0 -8
- package/dist/actions/get-booking-availability/mock.d.ts +0 -2
- package/dist/actions/get-booking-availability/mock.js +0 -6
- package/dist/actions/get-booking-availability/types.d.ts +0 -18
- package/dist/actions/get-booking-resources/action.d.ts +0 -6
- package/dist/actions/get-booking-resources/action.js +0 -8
- package/dist/actions/get-booking-resources/mock.d.ts +0 -2
- package/dist/actions/get-booking-resources/mock.js +0 -7
- package/dist/actions/get-booking-resources/types.d.ts +0 -12
- package/dist/actions/get-booking-resources/types.js +0 -1
- package/dist/actions/get-bookings/action.d.ts +0 -6
- package/dist/actions/get-bookings/action.js +0 -8
- package/dist/actions/get-bookings/mock.d.ts +0 -2
- package/dist/actions/get-bookings/mock.js +0 -20
- package/dist/actions/get-bookings/types.d.ts +0 -18
- package/dist/actions/get-bookings/types.js +0 -1
- package/dist/actions/hold-booking/action.d.ts +0 -6
- package/dist/actions/hold-booking/action.js +0 -8
- package/dist/actions/hold-booking/mock.d.ts +0 -2
- package/dist/actions/hold-booking/mock.js +0 -33
- package/dist/actions/hold-booking/types.d.ts +0 -24
- package/dist/actions/hold-booking/types.js +0 -1
- package/dist/actions/remove-booking-from-cart/action.d.ts +0 -6
- package/dist/actions/remove-booking-from-cart/action.js +0 -8
- package/dist/actions/remove-booking-from-cart/mock.d.ts +0 -2
- package/dist/actions/remove-booking-from-cart/mock.js +0 -26
- package/dist/actions/remove-booking-from-cart/types.d.ts +0 -12
- package/dist/actions/remove-booking-from-cart/types.js +0 -1
- package/dist/pubsub/topics/bookings/booking-created/types.d.ts +0 -6
- package/dist/pubsub/topics/bookings/booking-created/types.js +0 -1
- package/dist/pubsub/topics/bookings/booking-setup-changed/types.d.ts +0 -15
- package/dist/pubsub/topics/bookings/booking-setup-changed/types.js +0 -1
- package/dist/pubsub/topics/bookings/booking-updated/types.d.ts +0 -6
- package/dist/pubsub/topics/bookings/booking-updated/types.js +0 -1
- package/dist/pubsub/topics/bookings/index.d.ts +0 -3
- package/dist/pubsub/topics/bookings/index.js +0 -27
- package/dist/pubsub/topics/bookings/types.d.ts +0 -8
- package/dist/pubsub/topics/bookings/types.js +0 -3
- /package/dist/{actions/add-booking-to-cart → pubsub/topics/checkout/checkout-started}/types.js +0 -0
- /package/dist/{actions/cancel-booking → pubsub/topics/checkout/payment-completed}/types.js +0 -0
- /package/dist/{actions/get-booking-availability → pubsub/topics/checkout/payment-failed}/types.js +0 -0
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms,
|
|
1
|
+
import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms, CreatePaymentLink, ChargeMoto, StartCheckout, GetTimeClockStatus } from '../../index';
|
|
2
2
|
export interface RenderProviderActions {
|
|
3
3
|
exampleFunction: ExampleFunction;
|
|
4
4
|
getProducts: GetProducts;
|
|
5
|
-
getBookingResources: GetBookingResources;
|
|
6
|
-
getBookingAvailability: GetBookingAvailability;
|
|
7
|
-
getBookings: GetBookings;
|
|
8
|
-
holdBooking: HoldBooking;
|
|
9
|
-
addBookingToCart: AddBookingToCart;
|
|
10
|
-
removeBookingFromCart: RemoveBookingFromCart;
|
|
11
|
-
cancelBooking: CancelBooking;
|
|
12
5
|
addCustomSale: AddCustomSale;
|
|
13
6
|
editCustomSale: EditCustomSale;
|
|
14
7
|
getCustomers: GetCustomers;
|
|
@@ -50,6 +43,12 @@ export interface RenderProviderActions {
|
|
|
50
43
|
integrationPayment: IntegrationPayment;
|
|
51
44
|
createPaymentLink: CreatePaymentLink;
|
|
52
45
|
chargeMoto: ChargeMoto;
|
|
46
|
+
/**
|
|
47
|
+
* ONLINE checkout — served only by the storefront runtime (a published
|
|
48
|
+
* website). The till tenders above are refused there, and this is refused on
|
|
49
|
+
* a register, because the two declare different things to the card networks.
|
|
50
|
+
*/
|
|
51
|
+
startCheckout: StartCheckout;
|
|
53
52
|
addNonRevenueItem: AddNonRevenueItem;
|
|
54
53
|
addCustomerNote: AddCustomerNote;
|
|
55
54
|
removeCustomerNote: RemoveCustomerNote;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TopicEvent } from "../../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Payload for checkout-started event
|
|
4
|
+
*
|
|
5
|
+
* The order EXISTS and is unpaid. `serverTotal` is the server's own price for
|
|
6
|
+
* the cart, in integer minor units — the browser never sends a price, so this
|
|
7
|
+
* is the first and only authoritative total.
|
|
8
|
+
*/
|
|
9
|
+
export interface CheckoutStartedPayload {
|
|
10
|
+
orderId: string;
|
|
11
|
+
receiptId: string;
|
|
12
|
+
serverTotal: number;
|
|
13
|
+
currency: string;
|
|
14
|
+
/**
|
|
15
|
+
* `ready` — the payment fields are mounted and the shopper can pay.
|
|
16
|
+
* `unavailable` — the order exists but no payment could be started, so the
|
|
17
|
+
* shopper has NOT been charged.
|
|
18
|
+
*/
|
|
19
|
+
paymentStatus: "ready" | "unavailable";
|
|
20
|
+
/** One-time password for reading this order back. Returned only on the first create. */
|
|
21
|
+
orderPassword?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Typed event for checkout-started
|
|
25
|
+
*/
|
|
26
|
+
export type CheckoutStartedEvent = TopicEvent<CheckoutStartedPayload>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkout Topic Definition
|
|
3
|
+
* Defines the checkout topic and its available event types
|
|
4
|
+
*/
|
|
5
|
+
export const checkoutTopic = {
|
|
6
|
+
id: "checkout",
|
|
7
|
+
name: "Checkout",
|
|
8
|
+
description: "Topic for online (website) checkout events",
|
|
9
|
+
eventTypes: [
|
|
10
|
+
{
|
|
11
|
+
id: "checkout-started",
|
|
12
|
+
name: "Checkout Started",
|
|
13
|
+
description: "Published when the order has been created and the payment fields are mounted"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "payment-completed",
|
|
17
|
+
name: "Payment Completed",
|
|
18
|
+
description: "Published when the shopper's payment succeeds on their side (authorisation, not settlement)"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "payment-failed",
|
|
22
|
+
name: "Payment Failed",
|
|
23
|
+
description: "Published when a payment attempt is refused or errors; the shopper can retry"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
// Re-export types
|
|
28
|
+
export * from "./types";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TopicEvent } from "../../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Payload for payment-completed event
|
|
4
|
+
*
|
|
5
|
+
* THIS IS NOT SETTLEMENT. It reports that the SHOPPER'S side finished —
|
|
6
|
+
* `resultCode` is the provider's own outcome, typically `Authorised`. The money
|
|
7
|
+
* is confirmed by the provider's capture webhook reaching the backend, out of
|
|
8
|
+
* band and after this page is done, so this event cannot and does not claim it.
|
|
9
|
+
*/
|
|
10
|
+
export interface PaymentCompletedPayload {
|
|
11
|
+
orderId: string;
|
|
12
|
+
receiptId: string;
|
|
13
|
+
/** The provider's result code, e.g. `Authorised`. */
|
|
14
|
+
resultCode: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Typed event for payment-completed
|
|
18
|
+
*/
|
|
19
|
+
export type PaymentCompletedEvent = TopicEvent<PaymentCompletedPayload>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TopicEvent } from "../../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Payload for payment-failed event
|
|
4
|
+
*
|
|
5
|
+
* ONE DECLINED ATTEMPT, NOT A DEAD CHECKOUT. The order and the mounted payment
|
|
6
|
+
* fields both survive, so the shopper can try another card without the page
|
|
7
|
+
* starting a new checkout.
|
|
8
|
+
*/
|
|
9
|
+
export interface PaymentFailedPayload {
|
|
10
|
+
orderId: string;
|
|
11
|
+
receiptId: string;
|
|
12
|
+
/** The provider's result code, e.g. `Refused`, or an error name. */
|
|
13
|
+
resultCode: string;
|
|
14
|
+
/** Present when the failure carried a message worth showing. */
|
|
15
|
+
message?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Typed event for payment-failed
|
|
19
|
+
*/
|
|
20
|
+
export type PaymentFailedEvent = TopicEvent<PaymentFailedPayload>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkout Topic Types
|
|
3
|
+
* Aggregated types for all online-checkout events
|
|
4
|
+
*/
|
|
5
|
+
export * from "./checkout-started/types";
|
|
6
|
+
export * from "./payment-completed/types";
|
|
7
|
+
export * from "./payment-failed/types";
|
|
8
|
+
import type { CheckoutStartedPayload } from "./checkout-started/types";
|
|
9
|
+
import type { PaymentCompletedPayload } from "./payment-completed/types";
|
|
10
|
+
import type { PaymentFailedPayload } from "./payment-failed/types";
|
|
11
|
+
export type CheckoutEventPayload = CheckoutStartedPayload | PaymentCompletedPayload | PaymentFailedPayload;
|
|
12
|
+
export type CheckoutEventType = "checkout-started" | "payment-completed" | "payment-failed";
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
* Pub/Sub Topics
|
|
3
3
|
* Export all available topics and their types
|
|
4
4
|
*/
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
5
|
+
export * from "./customers";
|
|
6
|
+
export * from "./orders";
|
|
7
|
+
export * from "./refunds";
|
|
8
|
+
export * from "./products";
|
|
9
|
+
export * from "./cart";
|
|
10
|
+
export * from "./payments";
|
|
11
|
+
export * from "./checkout";
|
|
12
|
+
export * from "./custom-tables";
|
|
13
|
+
export * from "./print";
|
|
14
|
+
export * from "./outlet";
|
|
15
|
+
export * from "./station";
|
|
16
|
+
export * from "./session";
|
|
17
|
+
export * from "./users";
|
|
18
|
+
export * from "./variants";
|
|
19
|
+
export * from "./transactions";
|
|
20
|
+
export * from "./categories";
|
|
21
|
+
export * from "./attributes";
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
* Pub/Sub Topics
|
|
3
3
|
* Export all available topics and their types
|
|
4
4
|
*/
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
5
|
+
export * from "./customers";
|
|
6
|
+
export * from "./orders";
|
|
7
|
+
export * from "./refunds";
|
|
8
|
+
export * from "./products";
|
|
9
|
+
export * from "./cart";
|
|
10
|
+
export * from "./payments";
|
|
11
|
+
export * from "./checkout";
|
|
12
|
+
export * from "./custom-tables";
|
|
13
|
+
export * from "./print";
|
|
14
|
+
export * from "./outlet";
|
|
15
|
+
export * from "./station";
|
|
16
|
+
export * from "./session";
|
|
17
|
+
export * from "./users";
|
|
18
|
+
export * from "./variants";
|
|
19
|
+
export * from "./transactions";
|
|
20
|
+
export * from "./categories";
|
|
21
|
+
export * from "./attributes";
|
|
@@ -4,6 +4,7 @@ import { RefundsEventType, RefundsEventPayload } from "./refunds/types";
|
|
|
4
4
|
import { ProductsEventType, ProductsEventPayload } from "./products/types";
|
|
5
5
|
import { CartEventType, CartEventPayload } from "./cart/types";
|
|
6
6
|
import { PaymentsEventType, PaymentsEventPayload } from "./payments/types";
|
|
7
|
+
import { CheckoutEventType, CheckoutEventPayload } from "./checkout/types";
|
|
7
8
|
import { SplitPaymentsEventType, SplitPaymentsEventPayload } from "./split-payments/types";
|
|
8
9
|
import { CustomTablesEventPayload, CustomTablesEventType } from "./custom-tables/types";
|
|
9
10
|
import { PrintEventType, PrintEventPayload } from "./print/types";
|
|
@@ -15,7 +16,6 @@ import { VariantsEventType, VariantsEventPayload } from "./variants/types";
|
|
|
15
16
|
import { TransactionsEventType, TransactionsEventPayload } from "./transactions/types";
|
|
16
17
|
import { CategoriesEventType, CategoriesEventPayload } from "./categories/types";
|
|
17
18
|
import { AttributesEventType, AttributesEventPayload } from "./attributes/types";
|
|
18
|
-
import { BookingsEventType, BookingsEventPayload } from "./bookings/types";
|
|
19
19
|
export interface TopicEventPayloadMap {
|
|
20
20
|
customers: Record<CustomersEventType, CustomersEventPayload>;
|
|
21
21
|
orders: Record<OrdersEventType, OrdersEventPayload>;
|
|
@@ -23,6 +23,13 @@ export interface TopicEventPayloadMap {
|
|
|
23
23
|
products: Record<ProductsEventType, ProductsEventPayload>;
|
|
24
24
|
cart: Record<CartEventType, CartEventPayload>;
|
|
25
25
|
payments: Record<PaymentsEventType, PaymentsEventPayload>;
|
|
26
|
+
/**
|
|
27
|
+
* ONLINE checkout only (a published website), where the POS `payments`
|
|
28
|
+
* topic never fires: `payments` reports a till tender settling in front of
|
|
29
|
+
* a cashier, while a web shopper's outcome arrives asynchronously and can
|
|
30
|
+
* only ever be an authorisation until the provider's webhook lands.
|
|
31
|
+
*/
|
|
32
|
+
checkout: Record<CheckoutEventType, CheckoutEventPayload>;
|
|
26
33
|
"split-payments": Record<SplitPaymentsEventType, SplitPaymentsEventPayload>;
|
|
27
34
|
customTables: Record<CustomTablesEventType, CustomTablesEventPayload>;
|
|
28
35
|
print: Record<PrintEventType, PrintEventPayload>;
|
|
@@ -34,5 +41,4 @@ export interface TopicEventPayloadMap {
|
|
|
34
41
|
transactions: Record<TransactionsEventType, TransactionsEventPayload>;
|
|
35
42
|
categories: Record<CategoriesEventType, CategoriesEventPayload>;
|
|
36
43
|
attributes: Record<AttributesEventType, AttributesEventPayload>;
|
|
37
|
-
bookings: Record<BookingsEventType, BookingsEventPayload>;
|
|
38
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@final-commerce/command-frame",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-online.1",
|
|
4
4
|
"description": "Commands Frame library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"ignoreBranchesMissingTickets": true
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@final-commerce/common": "2.
|
|
60
|
+
"@final-commerce/common": "2.2.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@commitlint/cli": "^19.0.0",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Add booking to cart action
|
|
3
|
-
* Calls the addBookingToCart action on the parent window
|
|
4
|
-
*/
|
|
5
|
-
import { commandFrameClient } from '../../client';
|
|
6
|
-
export const addBookingToCart = async (params) => {
|
|
7
|
-
return await commandFrameClient.call('addBookingToCart', params);
|
|
8
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ReservationStatus } from '@final-commerce/common';
|
|
2
|
-
import { MOCK_CART, MOCK_PRODUCTS, mockPublishEvent } from '../../demo/database';
|
|
3
|
-
import { mockHoldBooking } from '../hold-booking/mock';
|
|
4
|
-
export const mockAddBookingToCart = async (params) => {
|
|
5
|
-
console.log('[Mock] addBookingToCart called', params);
|
|
6
|
-
// One call, two effects — the window is claimed AND the service is in the cart. The claim goes
|
|
7
|
-
// first and its refusal propagates: a cart line for a window somebody else took is worse than
|
|
8
|
-
// no line at all.
|
|
9
|
-
const { booking } = await mockHoldBooking(params);
|
|
10
|
-
const product = MOCK_PRODUCTS.find(({ _id }) => _id === params.productId);
|
|
11
|
-
const variant = params.variantId
|
|
12
|
-
? product?.variants?.find(({ _id }) => _id === params.variantId)
|
|
13
|
-
: product?.variants?.[0];
|
|
14
|
-
const price = variant?.price ?? product?.minPrice ?? 0;
|
|
15
|
-
const reservation = {
|
|
16
|
-
internalId: `res_${booking.id}`,
|
|
17
|
-
bookingId: booking.id,
|
|
18
|
-
productId: params.productId,
|
|
19
|
-
variantId: variant?._id ?? null,
|
|
20
|
-
resourceId: params.resourceId,
|
|
21
|
-
name: product?.name ?? 'Booking',
|
|
22
|
-
resourceName: booking.resourceName,
|
|
23
|
-
price,
|
|
24
|
-
quantity: 1,
|
|
25
|
-
total: price,
|
|
26
|
-
taxTableId: product?.taxTable,
|
|
27
|
-
startAt: booking.startAt,
|
|
28
|
-
endAt: booking.endAt,
|
|
29
|
-
bufferEndAt: booking.bufferEndAt,
|
|
30
|
-
status: ReservationStatus.HELD,
|
|
31
|
-
expiresAt: booking.expiresAt,
|
|
32
|
-
};
|
|
33
|
-
if (!MOCK_CART.reservations)
|
|
34
|
-
MOCK_CART.reservations = [];
|
|
35
|
-
MOCK_CART.reservations.push(reservation);
|
|
36
|
-
MOCK_CART.subtotal += price;
|
|
37
|
-
MOCK_CART.total += price;
|
|
38
|
-
MOCK_CART.amountToBeCharged = MOCK_CART.total;
|
|
39
|
-
MOCK_CART.remainingBalance = MOCK_CART.total;
|
|
40
|
-
// The cart topic, not the bookings one: a screen that only watches bookings still has to
|
|
41
|
-
// repaint its cart, and every other cart mutation announces itself the same way.
|
|
42
|
-
mockPublishEvent('cart', 'reservation-added', { reservation });
|
|
43
|
-
return { booking, reservationInternalId: reservation.internalId, timestamp: new Date().toISOString() };
|
|
44
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { CFBooking } from '../../CommonTypes';
|
|
2
|
-
export interface AddBookingToCartParams {
|
|
3
|
-
/** The bookable product (`productType: 'booking'`). */
|
|
4
|
-
productId: string;
|
|
5
|
-
/** Which resource serves it: a member of staff, a room, a scooter. */
|
|
6
|
-
resourceId: string;
|
|
7
|
-
/** Must be the START of a slot getBookingAvailability offered, ISO 8601. */
|
|
8
|
-
startAt: string;
|
|
9
|
-
/** End of the window — the slot's own `endAt`, or the last slot's for a stay. */
|
|
10
|
-
endAt: string;
|
|
11
|
-
/** The variant being sold. Defaults to the product's only variant. */
|
|
12
|
-
variantId?: string;
|
|
13
|
-
/** Whom the booking is for. Omit for a walk-in. */
|
|
14
|
-
customerId?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface AddBookingToCartResponse {
|
|
17
|
-
/** The claim the cart now stands on: `id` cancels or releases it, `expiresAt` is your clock. */
|
|
18
|
-
booking: CFBooking;
|
|
19
|
-
/** Identity of the reservation inside the cart and, later, the order. */
|
|
20
|
-
reservationInternalId: string;
|
|
21
|
-
timestamp: string;
|
|
22
|
-
}
|
|
23
|
-
export type AddBookingToCart = (params: AddBookingToCartParams) => Promise<AddBookingToCartResponse>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { MOCK_BOOKINGS } from '../../demo/database';
|
|
2
|
-
import { ReservationStatus } from '@final-commerce/common';
|
|
3
|
-
export const mockCancelBooking = async (params) => {
|
|
4
|
-
console.log('[Mock] cancelBooking called', params);
|
|
5
|
-
const booking = MOCK_BOOKINGS.find(({ id }) => id === params.bookingId);
|
|
6
|
-
if (!booking)
|
|
7
|
-
throw new Error(`No booking ${params.bookingId}`);
|
|
8
|
-
booking.status = ReservationStatus.CANCELLED;
|
|
9
|
-
return { booking, timestamp: new Date().toISOString() };
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CFBooking } from '../../CommonTypes';
|
|
2
|
-
export interface CancelBookingParams {
|
|
3
|
-
/** `id` of the booking returned by holdBooking or getBookings. */
|
|
4
|
-
bookingId: string;
|
|
5
|
-
}
|
|
6
|
-
export interface CancelBookingResponse {
|
|
7
|
-
booking: CFBooking;
|
|
8
|
-
timestamp: string;
|
|
9
|
-
}
|
|
10
|
-
export type CancelBooking = (params: CancelBookingParams) => Promise<CancelBookingResponse>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get booking availability action
|
|
3
|
-
* Calls the getBookingAvailability action on the parent window
|
|
4
|
-
*/
|
|
5
|
-
import { commandFrameClient } from '../../client';
|
|
6
|
-
export const getBookingAvailability = async (params) => {
|
|
7
|
-
return await commandFrameClient.call('getBookingAvailability', params);
|
|
8
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { mockBookingAvailability } from '../../demo/database';
|
|
2
|
-
export const mockGetBookingAvailability = async (params) => {
|
|
3
|
-
console.log('[Mock] getBookingAvailability called', params);
|
|
4
|
-
const availability = mockBookingAvailability(params.productId, new Date(params.from), new Date(params.to), params.resourceId);
|
|
5
|
-
return { availability, timestamp: new Date().toISOString() };
|
|
6
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CFBookingAvailability } from '../../CommonTypes';
|
|
2
|
-
export interface GetBookingAvailabilityParams {
|
|
3
|
-
/** The bookable product (`productType: 'booking'`) whose calendar you are drawing. */
|
|
4
|
-
productId: string;
|
|
5
|
-
/** Range start, ISO 8601. */
|
|
6
|
-
from: string;
|
|
7
|
-
/** Range end, ISO 8601. */
|
|
8
|
-
to: string;
|
|
9
|
-
/** Narrow the answer to one resource — "only Marco", "only room 4". */
|
|
10
|
-
resourceId?: string;
|
|
11
|
-
/** Narrow to the resources standing at one outlet. */
|
|
12
|
-
outletId?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface GetBookingAvailabilityResponse {
|
|
15
|
-
availability: CFBookingAvailability;
|
|
16
|
-
timestamp: string;
|
|
17
|
-
}
|
|
18
|
-
export type GetBookingAvailability = (params: GetBookingAvailabilityParams) => Promise<GetBookingAvailabilityResponse>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get booking resources action
|
|
3
|
-
* Calls the getBookingResources action on the parent window
|
|
4
|
-
*/
|
|
5
|
-
import { commandFrameClient } from '../../client';
|
|
6
|
-
export const getBookingResources = async (params) => {
|
|
7
|
-
return await commandFrameClient.call('getBookingResources', params);
|
|
8
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { MOCK_BOOKING_RESOURCES } from '../../demo/database';
|
|
2
|
-
export const mockGetBookingResources = async (params) => {
|
|
3
|
-
console.log('[Mock] getBookingResources called', params);
|
|
4
|
-
// A resource knows nothing about outlets — where it works lives in its own records, which the
|
|
5
|
-
// host reads. The mock has no such records, so `outletId` narrows nothing here.
|
|
6
|
-
return { resources: MOCK_BOOKING_RESOURCES, timestamp: new Date().toISOString() };
|
|
7
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CFBookingResource } from '../../CommonTypes';
|
|
2
|
-
export interface GetBookingResourcesParams {
|
|
3
|
-
/** Only the resources that serve this bookable product. Omit for the whole company. */
|
|
4
|
-
productId?: string;
|
|
5
|
-
/** Only resources standing at this outlet (a resource with no outlet serves all of them). */
|
|
6
|
-
outletId?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface GetBookingResourcesResponse {
|
|
9
|
-
resources: CFBookingResource[];
|
|
10
|
-
timestamp: string;
|
|
11
|
-
}
|
|
12
|
-
export type GetBookingResources = (params?: GetBookingResourcesParams) => Promise<GetBookingResourcesResponse>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { MOCK_BOOKINGS, mockLiveBookings } from '../../demo/database';
|
|
2
|
-
export const mockGetBookings = async (params) => {
|
|
3
|
-
console.log('[Mock] getBookings called', params);
|
|
4
|
-
let bookings = params?.includeExpired ? MOCK_BOOKINGS : mockLiveBookings();
|
|
5
|
-
if (params?.resourceId)
|
|
6
|
-
bookings = bookings.filter((entry) => entry.resourceId === params.resourceId);
|
|
7
|
-
if (params?.productId)
|
|
8
|
-
bookings = bookings.filter((entry) => entry.productId === params.productId);
|
|
9
|
-
if (params?.customerId)
|
|
10
|
-
bookings = bookings.filter((entry) => entry.customerId === params.customerId);
|
|
11
|
-
if (params?.from) {
|
|
12
|
-
const from = new Date(params.from);
|
|
13
|
-
bookings = bookings.filter((entry) => new Date(entry.bufferEndAt) > from);
|
|
14
|
-
}
|
|
15
|
-
if (params?.to) {
|
|
16
|
-
const to = new Date(params.to);
|
|
17
|
-
bookings = bookings.filter((entry) => new Date(entry.startAt) < to);
|
|
18
|
-
}
|
|
19
|
-
return { bookings, timestamp: new Date().toISOString() };
|
|
20
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CFBooking } from '../../CommonTypes';
|
|
2
|
-
export interface GetBookingsParams {
|
|
3
|
-
/** Everything taking this resource's time — the one query a day view needs. */
|
|
4
|
-
resourceId?: string;
|
|
5
|
-
productId?: string;
|
|
6
|
-
/** This customer's appointments. */
|
|
7
|
-
customerId?: string;
|
|
8
|
-
/** Bookings whose window overlaps this range, ISO 8601. */
|
|
9
|
-
from?: string;
|
|
10
|
-
to?: string;
|
|
11
|
-
/** Defaults to live bookings only (confirmed, plus holds that have not expired). */
|
|
12
|
-
includeExpired?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface GetBookingsResponse {
|
|
15
|
-
bookings: CFBooking[];
|
|
16
|
-
timestamp: string;
|
|
17
|
-
}
|
|
18
|
-
export type GetBookings = (params?: GetBookingsParams) => Promise<GetBookingsResponse>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|