@final-commerce/command-frame 0.7.0-staging.9 → 0.8.0-online.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/CommonTypes.d.ts +1 -26
  2. package/dist/actions/get-context/mock.js +0 -4
  3. package/dist/actions/get-refund-plan/types.d.ts +2 -5
  4. package/dist/actions/get-remaining-refundable-quantities/mock.js +0 -1
  5. package/dist/actions/get-remaining-refundable-quantities/types.d.ts +0 -8
  6. package/dist/actions/process-partial-refund/types.d.ts +2 -2
  7. package/dist/actions/resume-checkout/action.d.ts +6 -0
  8. package/dist/actions/resume-checkout/action.js +8 -0
  9. package/dist/actions/resume-checkout/mock.d.ts +16 -0
  10. package/dist/actions/resume-checkout/mock.js +51 -0
  11. package/dist/actions/resume-checkout/types.d.ts +59 -0
  12. package/dist/actions/resume-checkout/types.js +13 -0
  13. package/dist/actions/start-checkout/action.d.ts +6 -0
  14. package/dist/actions/start-checkout/action.js +8 -0
  15. package/dist/actions/start-checkout/mock.d.ts +16 -0
  16. package/dist/actions/start-checkout/mock.js +80 -0
  17. package/dist/actions/start-checkout/types.d.ts +81 -0
  18. package/dist/actions/start-checkout/types.js +10 -0
  19. package/dist/demo/database.d.ts +1 -12
  20. package/dist/demo/database.js +0 -127
  21. package/dist/index.d.ts +6 -16
  22. package/dist/index.js +5 -15
  23. package/dist/projects/render/mocks.js +4 -14
  24. package/dist/projects/render/types.d.ts +13 -8
  25. package/dist/pubsub/topics/checkout/checkout-started/types.d.ts +26 -0
  26. package/dist/pubsub/topics/checkout/index.d.ts +7 -0
  27. package/dist/pubsub/topics/checkout/index.js +28 -0
  28. package/dist/pubsub/topics/checkout/payment-completed/types.d.ts +31 -0
  29. package/dist/pubsub/topics/checkout/payment-failed/types.d.ts +20 -0
  30. package/dist/pubsub/topics/checkout/types.d.ts +12 -0
  31. package/dist/pubsub/topics/checkout/types.js +8 -0
  32. package/dist/pubsub/topics/index.d.ts +17 -17
  33. package/dist/pubsub/topics/index.js +17 -17
  34. package/dist/pubsub/topics/types.d.ts +8 -2
  35. package/package.json +2 -2
  36. package/dist/actions/add-booking-to-cart/action.d.ts +0 -6
  37. package/dist/actions/add-booking-to-cart/action.js +0 -8
  38. package/dist/actions/add-booking-to-cart/mock.d.ts +0 -2
  39. package/dist/actions/add-booking-to-cart/mock.js +0 -42
  40. package/dist/actions/add-booking-to-cart/types.d.ts +0 -23
  41. package/dist/actions/cancel-booking/action.d.ts +0 -6
  42. package/dist/actions/cancel-booking/action.js +0 -8
  43. package/dist/actions/cancel-booking/mock.d.ts +0 -2
  44. package/dist/actions/cancel-booking/mock.js +0 -10
  45. package/dist/actions/cancel-booking/types.d.ts +0 -10
  46. package/dist/actions/get-booking-availability/action.d.ts +0 -6
  47. package/dist/actions/get-booking-availability/action.js +0 -8
  48. package/dist/actions/get-booking-availability/mock.d.ts +0 -2
  49. package/dist/actions/get-booking-availability/mock.js +0 -6
  50. package/dist/actions/get-booking-availability/types.d.ts +0 -18
  51. package/dist/actions/get-booking-resources/action.d.ts +0 -6
  52. package/dist/actions/get-booking-resources/action.js +0 -8
  53. package/dist/actions/get-booking-resources/mock.d.ts +0 -2
  54. package/dist/actions/get-booking-resources/mock.js +0 -7
  55. package/dist/actions/get-booking-resources/types.d.ts +0 -12
  56. package/dist/actions/get-booking-resources/types.js +0 -1
  57. package/dist/actions/get-bookings/action.d.ts +0 -6
  58. package/dist/actions/get-bookings/action.js +0 -8
  59. package/dist/actions/get-bookings/mock.d.ts +0 -2
  60. package/dist/actions/get-bookings/mock.js +0 -20
  61. package/dist/actions/get-bookings/types.d.ts +0 -18
  62. package/dist/actions/get-bookings/types.js +0 -1
  63. package/dist/actions/hold-booking/action.d.ts +0 -6
  64. package/dist/actions/hold-booking/action.js +0 -8
  65. package/dist/actions/hold-booking/mock.d.ts +0 -2
  66. package/dist/actions/hold-booking/mock.js +0 -33
  67. package/dist/actions/hold-booking/types.d.ts +0 -24
  68. package/dist/actions/hold-booking/types.js +0 -1
  69. package/dist/actions/remove-booking-from-cart/action.d.ts +0 -6
  70. package/dist/actions/remove-booking-from-cart/action.js +0 -8
  71. package/dist/actions/remove-booking-from-cart/mock.d.ts +0 -2
  72. package/dist/actions/remove-booking-from-cart/mock.js +0 -26
  73. package/dist/actions/remove-booking-from-cart/types.d.ts +0 -12
  74. package/dist/actions/remove-booking-from-cart/types.js +0 -1
  75. package/dist/pubsub/topics/bookings/booking-created/types.d.ts +0 -6
  76. package/dist/pubsub/topics/bookings/booking-created/types.js +0 -1
  77. package/dist/pubsub/topics/bookings/booking-setup-changed/types.d.ts +0 -15
  78. package/dist/pubsub/topics/bookings/booking-setup-changed/types.js +0 -1
  79. package/dist/pubsub/topics/bookings/booking-updated/types.d.ts +0 -6
  80. package/dist/pubsub/topics/bookings/booking-updated/types.js +0 -1
  81. package/dist/pubsub/topics/bookings/index.d.ts +0 -3
  82. package/dist/pubsub/topics/bookings/index.js +0 -27
  83. package/dist/pubsub/topics/bookings/types.d.ts +0 -8
  84. package/dist/pubsub/topics/bookings/types.js +0 -3
  85. /package/dist/{actions/add-booking-to-cart → pubsub/topics/checkout/checkout-started}/types.js +0 -0
  86. /package/dist/{actions/cancel-booking → pubsub/topics/checkout/payment-completed}/types.js +0 -0
  87. /package/dist/{actions/get-booking-availability → pubsub/topics/checkout/payment-failed}/types.js +0 -0
@@ -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.7.0-staging.9",
3
+ "version": "0.8.0-online.2",
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.3.0-staging.6"
60
+ "@final-commerce/common": "2.2.2"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@commitlint/cli": "^19.0.0",
@@ -1,6 +0,0 @@
1
- /**
2
- * Add booking to cart action
3
- * Calls the addBookingToCart action on the parent window
4
- */
5
- import type { AddBookingToCart } from './types';
6
- export declare const addBookingToCart: AddBookingToCart;
@@ -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,2 +0,0 @@
1
- import { AddBookingToCart } from './types';
2
- export declare const mockAddBookingToCart: AddBookingToCart;
@@ -1,42 +0,0 @@
1
- import { MOCK_CART, MOCK_PRODUCTS, mockPublishEvent } from '../../demo/database';
2
- import { mockHoldBooking } from '../hold-booking/mock';
3
- export const mockAddBookingToCart = async (params) => {
4
- console.log('[Mock] addBookingToCart called', params);
5
- // One call, two effects — the window is claimed AND the service is in the cart. The claim goes
6
- // first and its refusal propagates: a cart line for a window somebody else took is worse than
7
- // no line at all.
8
- const { booking } = await mockHoldBooking(params);
9
- const product = MOCK_PRODUCTS.find(({ _id }) => _id === params.productId);
10
- const variant = params.variantId
11
- ? product?.variants?.find(({ _id }) => _id === params.variantId)
12
- : product?.variants?.[0];
13
- const price = variant?.price ?? product?.minPrice ?? 0;
14
- const reservation = {
15
- internalId: `res_${booking.id}`,
16
- bookingId: booking.id,
17
- productId: params.productId,
18
- variantId: variant?._id ?? null,
19
- resourceId: params.resourceId,
20
- name: product?.name ?? 'Booking',
21
- resourceName: booking.resourceName,
22
- price,
23
- quantity: 1,
24
- total: price,
25
- taxTableId: product?.taxTable,
26
- startAt: booking.startAt,
27
- endAt: booking.endAt,
28
- bufferEndAt: booking.bufferEndAt,
29
- expiresAt: booking.expiresAt,
30
- };
31
- if (!MOCK_CART.reservations)
32
- MOCK_CART.reservations = [];
33
- MOCK_CART.reservations.push(reservation);
34
- MOCK_CART.subtotal += price;
35
- MOCK_CART.total += price;
36
- MOCK_CART.amountToBeCharged = MOCK_CART.total;
37
- MOCK_CART.remainingBalance = MOCK_CART.total;
38
- // The cart topic, not the bookings one: a screen that only watches bookings still has to
39
- // repaint its cart, and every other cart mutation announces itself the same way.
40
- mockPublishEvent('cart', 'reservation-added', { reservation });
41
- return { booking, reservationInternalId: reservation.internalId, timestamp: new Date().toISOString() };
42
- };
@@ -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,6 +0,0 @@
1
- /**
2
- * Cancel booking action
3
- * Calls the cancelBooking action on the parent window
4
- */
5
- import type { CancelBooking } from './types';
6
- export declare const cancelBooking: CancelBooking;
@@ -1,8 +0,0 @@
1
- /**
2
- * Cancel booking action
3
- * Calls the cancelBooking action on the parent window
4
- */
5
- import { commandFrameClient } from '../../client';
6
- export const cancelBooking = async (params) => {
7
- return await commandFrameClient.call('cancelBooking', params);
8
- };
@@ -1,2 +0,0 @@
1
- import { CancelBooking } from './types';
2
- export declare const mockCancelBooking: CancelBooking;
@@ -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,6 +0,0 @@
1
- /**
2
- * Get booking availability action
3
- * Calls the getBookingAvailability action on the parent window
4
- */
5
- import type { GetBookingAvailability } from './types';
6
- export declare const getBookingAvailability: GetBookingAvailability;
@@ -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,2 +0,0 @@
1
- import { GetBookingAvailability } from './types';
2
- export declare const mockGetBookingAvailability: GetBookingAvailability;
@@ -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,6 +0,0 @@
1
- /**
2
- * Get booking resources action
3
- * Calls the getBookingResources action on the parent window
4
- */
5
- import type { GetBookingResources } from './types';
6
- export declare const getBookingResources: GetBookingResources;
@@ -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,2 +0,0 @@
1
- import { GetBookingResources } from './types';
2
- export declare const mockGetBookingResources: GetBookingResources;
@@ -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,6 +0,0 @@
1
- /**
2
- * Get bookings action
3
- * Calls the getBookings action on the parent window
4
- */
5
- import type { GetBookings } from './types';
6
- export declare const getBookings: GetBookings;
@@ -1,8 +0,0 @@
1
- /**
2
- * Get bookings action
3
- * Calls the getBookings action on the parent window
4
- */
5
- import { commandFrameClient } from '../../client';
6
- export const getBookings = async (params) => {
7
- return await commandFrameClient.call('getBookings', params);
8
- };
@@ -1,2 +0,0 @@
1
- import { GetBookings } from './types';
2
- export declare const mockGetBookings: GetBookings;
@@ -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 {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Hold booking action
3
- * Calls the holdBooking action on the parent window
4
- */
5
- import type { HoldBooking } from './types';
6
- export declare const holdBooking: HoldBooking;
@@ -1,8 +0,0 @@
1
- /**
2
- * Hold booking action
3
- * Calls the holdBooking action on the parent window
4
- */
5
- import { commandFrameClient } from '../../client';
6
- export const holdBooking = async (params) => {
7
- return await commandFrameClient.call('holdBooking', params);
8
- };
@@ -1,2 +0,0 @@
1
- import { HoldBooking } from './types';
2
- export declare const mockHoldBooking: HoldBooking;
@@ -1,33 +0,0 @@
1
- import { MOCK_BOOKINGS, MOCK_BOOKING_RESOURCES, mockLiveBookings } from '../../demo/database';
2
- import { ReservationStatus } from '@final-commerce/common';
3
- const BUFFER_MINUTES = 5;
4
- const HOLD_MINUTES = 10;
5
- export const mockHoldBooking = async (params) => {
6
- console.log('[Mock] holdBooking called', params);
7
- const startAt = new Date(params.startAt);
8
- const endAt = new Date(params.endAt);
9
- const bufferEndAt = new Date(endAt.getTime() + BUFFER_MINUTES * 60000);
10
- // The mock refuses a taken window like the host does. A mock that always said yes would
11
- // let a booking screen ship without ever handling the one error it will actually meet.
12
- const clash = mockLiveBookings().some((entry) => entry.resourceId === params.resourceId &&
13
- new Date(entry.startAt) < bufferEndAt &&
14
- new Date(entry.bufferEndAt) > startAt);
15
- if (clash)
16
- throw new Error('That window has just been taken — pick another slot.');
17
- const booking = {
18
- id: `bk_mock_${Date.now()}`,
19
- productId: params.productId,
20
- resourceId: params.resourceId,
21
- variantId: params.variantId,
22
- startAt: startAt.toISOString(),
23
- endAt: endAt.toISOString(),
24
- bufferEndAt: bufferEndAt.toISOString(),
25
- customerId: params.customerId,
26
- status: ReservationStatus.HELD,
27
- expiresAt: new Date(Date.now() + HOLD_MINUTES * 60000).toISOString(),
28
- resourceName: MOCK_BOOKING_RESOURCES.find(({ id }) => id === params.resourceId)?.name,
29
- };
30
- // Held in the same list availability reads, so the slot really does disappear.
31
- MOCK_BOOKINGS.push(booking);
32
- return { booking, timestamp: new Date().toISOString() };
33
- };
@@ -1,24 +0,0 @@
1
- import { CFBooking } from '../../CommonTypes';
2
- export interface HoldBookingParams {
3
- productId: string;
4
- /** Which resource serves it: a member of staff, a room, a scooter. */
5
- resourceId: string;
6
- /** Must be the START of a slot the host offered, ISO 8601. */
7
- startAt: string;
8
- /**
9
- * End of the window — the `endAt` of the slot you picked, or of the last slot in a stay.
10
- * Required: the server refuses a window it cannot line up with its own grid, and the till
11
- * has no local copy of the rules to derive it from.
12
- */
13
- endAt: string;
14
- /** The variant being sold, when the flow already knows which one. */
15
- variantId?: string;
16
- /** Whom the booking is for. Omit for a walk-in. */
17
- customerId?: string;
18
- }
19
- export interface HoldBookingResponse {
20
- /** The claim. `expiresAt` says how long it survives unpaid; `id` is what you confirm or cancel. */
21
- booking: CFBooking;
22
- timestamp: string;
23
- }
24
- export type HoldBooking = (params: HoldBookingParams) => Promise<HoldBookingResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Remove booking from cart action
3
- * Calls the removeBookingFromCart action on the parent window
4
- */
5
- import type { RemoveBookingFromCart } from './types';
6
- export declare const removeBookingFromCart: RemoveBookingFromCart;
@@ -1,8 +0,0 @@
1
- /**
2
- * Remove booking from cart action
3
- * Calls the removeBookingFromCart action on the parent window
4
- */
5
- import { commandFrameClient } from '../../client';
6
- export const removeBookingFromCart = async (params) => {
7
- return await commandFrameClient.call('removeBookingFromCart', params);
8
- };
@@ -1,2 +0,0 @@
1
- import { RemoveBookingFromCart } from './types';
2
- export declare const mockRemoveBookingFromCart: RemoveBookingFromCart;
@@ -1,26 +0,0 @@
1
- import { MOCK_BOOKINGS, MOCK_CART, mockPublishEvent } from '../../demo/database';
2
- export const mockRemoveBookingFromCart = async (params) => {
3
- console.log('[Mock] removeBookingFromCart called', params);
4
- const reservations = MOCK_CART.reservations ?? [];
5
- const cartIndex = reservations.findIndex(({ internalId }) => internalId === params.reservationInternalId);
6
- const [removed] = cartIndex >= 0 ? reservations.splice(cartIndex, 1) : [];
7
- if (removed) {
8
- const line = removed.total || removed.price * (removed.quantity ?? 1);
9
- MOCK_CART.subtotal -= line;
10
- MOCK_CART.total -= line;
11
- MOCK_CART.amountToBeCharged = MOCK_CART.total;
12
- MOCK_CART.remainingBalance = MOCK_CART.total;
13
- mockPublishEvent('cart', 'reservation-removed', { reservation: removed });
14
- }
15
- // The hold has to go back, or the mock is a trap: `addBookingToCart` pushes into the very list
16
- // availability reads, so add → remove → add the same slot used to refuse forever with "that
17
- // window has just been taken". The reservation id is `res_<booking.id>`, the link back to the row.
18
- const bookingId = removed?.bookingId ?? params.reservationInternalId.replace(/^res_/, '');
19
- const index = MOCK_BOOKINGS.findIndex(({ id }) => id === bookingId);
20
- const [released] = index >= 0 ? MOCK_BOOKINGS.splice(index, 1) : [];
21
- return {
22
- reservationInternalId: params.reservationInternalId,
23
- booking: released,
24
- timestamp: new Date().toISOString(),
25
- };
26
- };
@@ -1,12 +0,0 @@
1
- import { CFBooking } from '../../CommonTypes';
2
- export interface RemoveBookingFromCartParams {
3
- /** The reservation's own id, as `addBookingToCart` returned it. */
4
- reservationInternalId: string;
5
- }
6
- export interface RemoveBookingFromCartResponse {
7
- reservationInternalId: string;
8
- /** The released hold, so the caller can see it is no longer held. */
9
- booking?: CFBooking;
10
- timestamp: string;
11
- }
12
- export type RemoveBookingFromCart = (params: RemoveBookingFromCartParams) => Promise<RemoveBookingFromCartResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import type { CFBooking } from '../../../../CommonTypes';
2
- import type { TopicEvent } from '../../../types';
3
- export interface BookingCreatedPayload {
4
- booking: CFBooking;
5
- }
6
- export type BookingCreatedEvent = TopicEvent<BookingCreatedPayload>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import type { TopicEvent } from '../../../types';
2
- /**
3
- * What a booking can be MADE of changed — a rule set, a resource, who serves a product, or where
4
- * a resource works. Occupancy is untouched.
5
- *
6
- * Deliberately carries no row: the change can span several collections at once (a rule set edited
7
- * AND a product↔resource link removed), and a subscriber cannot act on a partial picture anyway.
8
- * The only correct reaction is to re-ask `getBookingResources` and `getBookingAvailability`,
9
- * because both previous answers were computed from the old setup.
10
- */
11
- export interface BookingSetupChangedPayload {
12
- /** Which collection moved, when the host knows: `booking-rules`, `booking-resources`, … */
13
- collection?: string;
14
- }
15
- export type BookingSetupChangedEvent = TopicEvent<BookingSetupChangedPayload>;
@@ -1,6 +0,0 @@
1
- import type { CFBooking } from '../../../../CommonTypes';
2
- import type { TopicEvent } from '../../../types';
3
- export interface BookingUpdatedPayload {
4
- booking: CFBooking;
5
- }
6
- export type BookingUpdatedEvent = TopicEvent<BookingUpdatedPayload>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import type { TopicDefinition } from '../../types';
2
- export declare const bookingsTopic: TopicDefinition;
3
- export * from './types';
@@ -1,27 +0,0 @@
1
- export const bookingsTopic = {
2
- id: 'bookings',
3
- name: 'Bookings',
4
- description: 'Topic for bookings synced from the database. A booking IS the occupancy, so this is the ' +
5
- 'signal that somebody else took (or freed) a window: re-ask getBookingAvailability when it ' +
6
- 'fires instead of polling the server on a timer.',
7
- eventTypes: [
8
- {
9
- id: 'booking-created',
10
- name: 'Booking Created',
11
- description: 'Published when a booking made elsewhere — another till, the back office — is synced in',
12
- },
13
- {
14
- id: 'booking-updated',
15
- name: 'Booking Updated',
16
- description: 'Published when a synced booking changes: confirmed after payment, cancelled, or expired',
17
- },
18
- {
19
- id: 'booking-setup-changed',
20
- name: 'Booking Setup Changed',
21
- description: 'Published when what a booking can be MADE of changes: a rule set, a resource, who serves ' +
22
- 'a product, or where a resource works. Occupancy is untouched — re-ask getBookingResources ' +
23
- 'and getBookingAvailability, because both answers were computed from the old setup.',
24
- },
25
- ],
26
- };
27
- export * from './types';
@@ -1,8 +0,0 @@
1
- export * from './booking-created/types';
2
- export * from './booking-updated/types';
3
- export * from './booking-setup-changed/types';
4
- import type { BookingCreatedPayload } from './booking-created/types';
5
- import type { BookingUpdatedPayload } from './booking-updated/types';
6
- import type { BookingSetupChangedPayload } from './booking-setup-changed/types';
7
- export type BookingsEventPayload = BookingCreatedPayload | BookingUpdatedPayload | BookingSetupChangedPayload;
8
- export type BookingsEventType = 'booking-created' | 'booking-updated' | 'booking-setup-changed';
@@ -1,3 +0,0 @@
1
- export * from './booking-created/types';
2
- export * from './booking-updated/types';
3
- export * from './booking-setup-changed/types';