@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,7 +4,6 @@
4
4
  */
5
5
  import { CFProductType, CFUserTypes, CurrencyCode, } from '../CommonTypes';
6
6
  import { extendPrice, resolveUnit, toBase } from '@final-commerce/common';
7
- import { BookingRatePeriod, BookingResourceKind, BookingType, ReservationStatus } from '@final-commerce/common';
8
7
  export * from './mocks';
9
8
  // Asset Imports - Using Remote URLs to avoid build complexity with asset copying
10
9
  const ASSETS_BASE_URL = 'https://raw.githubusercontent.com/Final-Commerce/command-frame/refs/heads/main/src/demo/assets';
@@ -650,14 +649,6 @@ export const MOCK_CATEGORIES = [
650
649
  MOCK_CATEGORY_VEGAN,
651
650
  MOCK_CATEGORY_SPICY,
652
651
  ];
653
- // A service, not a thing on a shelf: no stock, sold as a slot of somebody's time.
654
- // `bookingRulesId` is what tells a catalogue screen to ask for slots instead of stock.
655
- export const MOCK_PRODUCT_HAIRCUT = {
656
- ...createSimpleProduct('prod_haircut', 'Haircut', 4500, '', [MOCK_CATEGORY_SPECIALTY], 'Cut and finish, 30 minutes.'),
657
- images: [],
658
- productType: CFProductType.BOOKING,
659
- bookingRulesId: 'rule_salon_30',
660
- };
661
652
  export const MOCK_PRODUCTS = [
662
653
  MOCK_PRODUCT_BASIL_ALMOND,
663
654
  MOCK_PRODUCT_BEER,
@@ -673,7 +664,6 @@ export const MOCK_PRODUCTS = [
673
664
  MOCK_PRODUCT_CHILI_GARLIC,
674
665
  MOCK_PRODUCT_HABANERO,
675
666
  MOCK_PRODUCT_BLACK_GARLIC,
676
- MOCK_PRODUCT_HAIRCUT,
677
667
  ];
678
668
  export const MOCK_ORDERS = [MOCK_ORDER_1, MOCK_ORDER_2, MOCK_ORDER_3, MOCK_ORDER_4];
679
669
  export const MOCK_PARKED_ORDERS = [MOCK_PARKED_ORDER_1, MOCK_PARKED_ORDER_2];
@@ -688,7 +678,6 @@ export let MOCK_CART = {
688
678
  remainingBalance: 0,
689
679
  products: [],
690
680
  customSales: [],
691
- reservations: [],
692
681
  nonRevenueItems: [],
693
682
  customer: null,
694
683
  };
@@ -709,7 +698,6 @@ export const resetMockCart = () => {
709
698
  remainingBalance: 0,
710
699
  products: [],
711
700
  customSales: [],
712
- reservations: [],
713
701
  nonRevenueItems: [],
714
702
  customer: null,
715
703
  };
@@ -754,12 +742,6 @@ export function setMockDatabase(config) {
754
742
  if (config.parkedOrders !== undefined) {
755
743
  MOCK_PARKED_ORDERS.splice(0, MOCK_PARKED_ORDERS.length, ...config.parkedOrders);
756
744
  }
757
- if (config.bookingResources !== undefined) {
758
- MOCK_BOOKING_RESOURCES.splice(0, MOCK_BOOKING_RESOURCES.length, ...config.bookingResources);
759
- }
760
- if (config.bookings !== undefined) {
761
- MOCK_BOOKINGS.splice(0, MOCK_BOOKINGS.length, ...config.bookings);
762
- }
763
745
  if (MOCK_OUTLETS.length > 0) {
764
746
  Object.assign(MOCK_OUTLET_MAIN, MOCK_OUTLETS[0]);
765
747
  if (MOCK_OUTLET_MAIN.id === undefined && MOCK_OUTLET_MAIN._id !== undefined) {
@@ -896,30 +878,6 @@ export const createOrderFromCart = (paymentType, amount, processor = 'cash') =>
896
878
  billing: MOCK_CART.customer?.billing || null,
897
879
  shipping: MOCK_CART.customer?.shipping || null,
898
880
  lineItems,
899
- // A paid booking is a sale: it belongs on the order (and thus the receipt),
900
- // in its own array rather than among the line items, and CONFIRMED — payment
901
- // is what turns a held window into a kept appointment.
902
- reservations: (MOCK_CART.reservations ?? []).map((reservation) => ({
903
- internalId: reservation.internalId,
904
- bookingId: reservation.bookingId,
905
- productId: reservation.productId,
906
- variantId: reservation.variantId,
907
- resourceId: reservation.resourceId,
908
- name: reservation.name,
909
- resourceName: reservation.resourceName,
910
- price: reservation.price,
911
- quantity: reservation.quantity,
912
- total: reservation.total,
913
- taxTableId: reservation.taxTableId,
914
- startAt: reservation.startAt,
915
- endAt: reservation.endAt,
916
- bufferEndAt: reservation.bufferEndAt,
917
- // The mock computes no tax anywhere — line items ship `taxes: []` too.
918
- taxes: [],
919
- // Neither `expiresAt` nor a status comes along: a booking's state lives on its own
920
- // row — which is what `getBookings` reads — and a copy frozen on the order would be
921
- // wrong from the next moment on.
922
- })),
923
881
  customSales: [],
924
882
  balance: 0,
925
883
  user: employeeUser,
@@ -956,88 +914,3 @@ export const applyMockPayment = (amount, paymentType, processor = 'cash') => {
956
914
  mockPublishEvent('payments', 'payment-done', { order });
957
915
  return order;
958
916
  };
959
- // ── Booking (FT-0064) ────────────────────────────────────────────────────────────
960
- // A salon: one service, two people who can perform it, a 30-minute slot with a
961
- // 5-minute turnaround, open 9–18. Enough to click through a booking screen with no
962
- // server. Availability here is COMPUTED, exactly as the host computes it — a mock
963
- // that returned a fixed list of slots would hide the one behaviour that matters:
964
- // a slot disappears once somebody takes it.
965
- export const MOCK_BOOKING_RULES_ID = 'rule_salon_30';
966
- const SLOT_MINUTES = 30;
967
- const BUFFER_MINUTES = 5;
968
- const OPEN_HOUR = 9;
969
- const CLOSE_HOUR = 18;
970
- // Rooms, not people: a resource is whatever is scarce, and a room is the case that
971
- // reads the same in every vertical a dataset might describe.
972
- export const MOCK_BOOKING_RESOURCES = [
973
- { id: 'res_room_1', name: 'Room 1', kind: BookingResourceKind.ROOM },
974
- { id: 'res_room_2', name: 'Room 2', kind: BookingResourceKind.ROOM },
975
- ];
976
- const at = (dayOffset, hour, minute = 0) => {
977
- const date = new Date();
978
- date.setDate(date.getDate() + dayOffset);
979
- date.setHours(hour, minute, 0, 0);
980
- return date;
981
- };
982
- const booking = (id, resourceId, start, status, customerName) => ({
983
- id,
984
- productId: MOCK_PRODUCT_HAIRCUT._id,
985
- resourceId,
986
- startAt: start.toISOString(),
987
- endAt: new Date(start.getTime() + SLOT_MINUTES * 60000).toISOString(),
988
- bufferEndAt: new Date(start.getTime() + (SLOT_MINUTES + BUFFER_MINUTES) * 60000).toISOString(),
989
- status,
990
- productName: MOCK_PRODUCT_HAIRCUT.name,
991
- resourceName: MOCK_BOOKING_RESOURCES.find((resource) => resource.id === resourceId)?.name,
992
- customerName,
993
- });
994
- export const MOCK_BOOKINGS = [
995
- booking('bk_1', 'res_room_1', at(0, 10), ReservationStatus.CONFIRMED, 'Alex Green'),
996
- booking('bk_2', 'res_room_2', at(0, 11, 30), ReservationStatus.CONFIRMED, 'Dana White'),
997
- booking('bk_3', 'res_room_1', at(1, 9, 30), ReservationStatus.CONFIRMED, 'Sam Blue'),
998
- ];
999
- /** Live = confirmed, or held and not yet expired. An expired hold occupies nothing. */
1000
- export const mockLiveBookings = () => MOCK_BOOKINGS.filter(({ status, expiresAt }) => status === ReservationStatus.CONFIRMED ||
1001
- (status === ReservationStatus.HELD && (!expiresAt || new Date(expiresAt) > new Date())));
1002
- const takenBy = (resourceId, startAt, bufferEndAt) => mockLiveBookings().some((entry) => entry.resourceId === resourceId && new Date(entry.startAt) < bufferEndAt && new Date(entry.bufferEndAt) > startAt);
1003
- export const mockBookingAvailability = (productId, from, to, resourceId) => {
1004
- const serving = resourceId
1005
- ? MOCK_BOOKING_RESOURCES.filter((resource) => resource.id === resourceId)
1006
- : MOCK_BOOKING_RESOURCES;
1007
- const slots = [];
1008
- const step = (SLOT_MINUTES + BUFFER_MINUTES) * 60000;
1009
- for (let day = 0; day < 14; day += 1) {
1010
- const open = at(day, OPEN_HOUR);
1011
- if (open < from || open > to)
1012
- continue;
1013
- const close = at(day, CLOSE_HOUR);
1014
- for (let start = open.getTime(); start + SLOT_MINUTES * 60000 <= close.getTime(); start += step) {
1015
- const startAt = new Date(start);
1016
- const endAt = new Date(start + SLOT_MINUTES * 60000);
1017
- const bufferEndAt = new Date(start + (SLOT_MINUTES + BUFFER_MINUTES) * 60000);
1018
- if (bufferEndAt < new Date())
1019
- continue;
1020
- const resources = serving.map((resource) => {
1021
- const free = takenBy(resource.id, startAt, bufferEndAt) ? 0 : 1;
1022
- return { resourceId: resource.id, name: resource.name, capacity: 1, booked: 1 - free, free };
1023
- });
1024
- slots.push({
1025
- startAt: startAt.toISOString(),
1026
- endAt: endAt.toISOString(),
1027
- bufferEndAt: bufferEndAt.toISOString(),
1028
- canStart: true,
1029
- capacity: resources.length,
1030
- booked: resources.reduce((sum, entry) => sum + entry.booked, 0),
1031
- free: resources.reduce((sum, entry) => sum + entry.free, 0),
1032
- resources,
1033
- });
1034
- }
1035
- }
1036
- return {
1037
- productId,
1038
- bookingRulesId: MOCK_BOOKING_RULES_ID,
1039
- bookingType: BookingType.APPOINTMENT,
1040
- ratePeriod: BookingRatePeriod.SLOT,
1041
- slots,
1042
- };
1043
- };
package/dist/index.d.ts CHANGED
@@ -2,13 +2,6 @@ export declare const command: {
2
2
  readonly exampleFunction: import(".").ExampleFunction;
3
3
  readonly generateAPIKey: import(".").GenerateAPIKey;
4
4
  readonly getProducts: import(".").GetProducts;
5
- readonly getBookingResources: import(".").GetBookingResources;
6
- readonly getBookingAvailability: import(".").GetBookingAvailability;
7
- readonly getBookings: import(".").GetBookings;
8
- readonly holdBooking: import(".").HoldBooking;
9
- readonly addBookingToCart: import(".").AddBookingToCart;
10
- readonly removeBookingFromCart: import(".").RemoveBookingFromCart;
11
- readonly cancelBooking: import(".").CancelBooking;
12
5
  readonly addCustomSale: import(".").AddCustomSale;
13
6
  readonly editCustomSale: import(".").EditCustomSale;
14
7
  readonly addNonRevenueItem: import(".").AddNonRevenueItem;
@@ -50,6 +43,8 @@ export declare const command: {
50
43
  readonly integrationPayment: import(".").IntegrationPayment;
51
44
  readonly createPaymentLink: import(".").CreatePaymentLink;
52
45
  readonly chargeMoto: import(".").ChargeMoto;
46
+ readonly startCheckout: import(".").StartCheckout;
47
+ readonly resumeCheckout: import(".").ResumeCheckout;
53
48
  readonly addCustomerNote: import(".").AddCustomerNote;
54
49
  readonly removeCustomerNote: import(".").RemoveCustomerNote;
55
50
  readonly removeCustomerFromCart: import(".").RemoveCustomerFromCart;
@@ -126,13 +121,6 @@ export declare const command: {
126
121
  export type { ExampleFunction, ExampleFunctionParams, ExampleFunctionResponse } from './actions/example-function/types';
127
122
  export type { GenerateAPIKey, GenerateAPIKeyParams, GenerateAPIKeyResponse } from './actions/generate-api-key/types';
128
123
  export type { GetProducts, GetProductsParams, GetProductsResponse } from './actions/get-products/types';
129
- export type { GetBookingResources, GetBookingResourcesParams, GetBookingResourcesResponse, } from './actions/get-booking-resources/types';
130
- export type { GetBookingAvailability, GetBookingAvailabilityParams, GetBookingAvailabilityResponse, } from './actions/get-booking-availability/types';
131
- export type { GetBookings, GetBookingsParams, GetBookingsResponse } from './actions/get-bookings/types';
132
- export type { HoldBooking, HoldBookingParams, HoldBookingResponse } from './actions/hold-booking/types';
133
- export type { AddBookingToCart, AddBookingToCartParams, AddBookingToCartResponse, } from './actions/add-booking-to-cart/types';
134
- export type { RemoveBookingFromCart, RemoveBookingFromCartParams, RemoveBookingFromCartResponse, } from './actions/remove-booking-from-cart/types';
135
- export type { CancelBooking, CancelBookingParams, CancelBookingResponse } from './actions/cancel-booking/types';
136
124
  export type { AddCustomSale, AddCustomSaleParams, AddCustomSaleResponse } from './actions/add-custom-sale/types';
137
125
  export type { EditCustomSale, EditCustomSaleParams, EditCustomSaleResponse } from './actions/edit-custom-sale/types';
138
126
  export type { AddNonRevenueItem, AddNonRevenueItemParams, AddNonRevenueItemResponse, } from './actions/add-non-revenue-item/types';
@@ -192,6 +180,8 @@ export type { RedeemPayment, RedeemPaymentParams, RedeemPaymentResponse } from '
192
180
  export type { IntegrationPayment, IntegrationPaymentParams, IntegrationPaymentResponse, IntegrationEmvData, } from './actions/integration-payment/types';
193
181
  export type { CreatePaymentLink, CreatePaymentLinkParams, CreatePaymentLinkResponse, } from './actions/create-payment-link/types';
194
182
  export type { ChargeMoto, ChargeMotoParams, ChargeMotoResponse, ChargeMotoCardFields, } from './actions/charge-moto/types';
183
+ export type { StartCheckout, StartCheckoutParams, StartCheckoutResponse, StartCheckoutContact, StartCheckoutOrder, } from './actions/start-checkout/types';
184
+ export type { ResumeCheckout, ResumeCheckoutParams, ResumeCheckoutResponse, ResumeCheckoutResult, } from './actions/resume-checkout/types';
195
185
  export type { AddCustomerNote, AddCustomerNoteParams, AddCustomerNoteResponse, } from './actions/add-customer-note/types';
196
186
  export type { RemoveCustomerNote, RemoveCustomerNoteParams, RemoveCustomerNoteResponse, } from './actions/remove-customer-note/types';
197
187
  export type { RemoveCustomerFromCart, RemoveCustomerFromCartResponse } from './actions/remove-customer-from-cart/types';
@@ -248,6 +238,7 @@ export { refundsTopic } from './pubsub/topics/refunds';
248
238
  export { productsTopic } from './pubsub/topics/products';
249
239
  export { cartTopic } from './pubsub/topics/cart';
250
240
  export { paymentsTopic } from './pubsub/topics/payments';
241
+ export { checkoutTopic } from './pubsub/topics/checkout';
251
242
  export { splitPaymentsTopic } from './pubsub/topics/split-payments';
252
243
  export { customTablesTopic } from './pubsub/topics/custom-tables';
253
244
  export { printTopic } from './pubsub/topics/print';
@@ -259,7 +250,6 @@ export { variantsTopic } from './pubsub/topics/variants';
259
250
  export { transactionsTopic } from './pubsub/topics/transactions';
260
251
  export { categoriesTopic } from './pubsub/topics/categories';
261
252
  export { attributesTopic } from './pubsub/topics/attributes';
262
- export { bookingsTopic } from './pubsub/topics/bookings';
263
253
  export type { CustomerCreatedPayload, CustomerUpdatedPayload, CustomerNoteAddedPayload, CustomerNoteDeletedPayload, CustomerAssignedPayload, CustomerUnassignedPayload, CustomerActiveSetPayload, CustomerActiveGetPayload, CustomerCreatedEvent, CustomerUpdatedEvent, CustomerNoteAddedEvent, CustomerNoteDeletedEvent, CustomerAssignedEvent, CustomerUnassignedEvent, CustomerActiveSetEvent, CustomerActiveGetEvent, CustomersEventType, CustomersEventPayload, } from './pubsub/topics/customers/types';
264
254
  export type { OrderCreatedPayload, OrderUpdatedPayload, OrderVoidedPayload, OrderActiveSetPayload, OrderActiveGetPayload, OrderCreatedEvent, OrderUpdatedEvent, OrderVoidedEvent, OrderActiveSetEvent, OrderActiveGetEvent, OrderStateTransitionCompletedPayload, OrderStateTransitionBlockedPayload, OrderStateTransitionCompletedEvent, OrderStateTransitionBlockedEvent, OrdersEventType, OrdersEventPayload, } from './pubsub/topics/orders/types';
265
255
  export type { RefundCreatedPayload, RefundUpdatedPayload, RefundActiveSetPayload, RefundActiveGetPayload, RefundCreatedEvent, RefundUpdatedEvent, RefundActiveSetEvent, RefundActiveGetEvent, RefundsEventType, RefundsEventPayload, } from './pubsub/topics/refunds/types';
@@ -270,11 +260,11 @@ export type { SessionActiveSetPayload, SessionActiveGetPayload, SessionActiveSet
270
260
  export type { UserActiveSetPayload, UserActiveGetPayload, UserActiveSetEvent, UserActiveGetEvent, UserCreatedPayload, UserCreatedEvent, UserUpdatedPayload, UserUpdatedEvent, UsersEventType, UsersEventPayload, } from './pubsub/topics/users/types';
271
261
  export type { VariantCreatedPayload, VariantCreatedEvent, VariantUpdatedPayload, VariantUpdatedEvent, VariantsEventType, VariantsEventPayload, } from './pubsub/topics/variants/types';
272
262
  export type { TransactionCreatedPayload, TransactionCreatedEvent, TransactionUpdatedPayload, TransactionUpdatedEvent, TransactionsEventType, TransactionsEventPayload, } from './pubsub/topics/transactions/types';
273
- export type { BookingCreatedPayload, BookingCreatedEvent, BookingUpdatedPayload, BookingUpdatedEvent, BookingSetupChangedPayload, BookingSetupChangedEvent, BookingsEventType, BookingsEventPayload, } from './pubsub/topics/bookings/types';
274
263
  export type { CategoryCreatedPayload, CategoryCreatedEvent, CategoryUpdatedPayload, CategoryUpdatedEvent, CategoriesEventType, CategoriesEventPayload, } from './pubsub/topics/categories/types';
275
264
  export type { AttributeCreatedPayload, AttributeCreatedEvent, AttributeUpdatedPayload, AttributeUpdatedEvent, AttributesEventType, AttributesEventPayload, } from './pubsub/topics/attributes/types';
276
265
  export type { CartCreatedPayload, CartCustomerAssignedPayload, ProductAddedPayload, ProductDeletedPayload, CartDiscountAddedPayload, CartDiscountRemovedPayload, CartFeeAddedPayload, CartFeeRemovedPayload, ProductDiscountAddedPayload, ProductDiscountRemovedPayload, ProductFeeAddedPayload, ProductFeeRemovedPayload, ProductNoteAddedPayload, ProductNoteRemovedPayload, CartCreatedEvent, CartCustomerAssignedEvent, ProductAddedEvent, ProductDeletedEvent, CartDiscountAddedEvent, CartDiscountRemovedEvent, CartFeeAddedEvent, CartFeeRemovedEvent, ProductDiscountAddedEvent, ProductDiscountRemovedEvent, ProductFeeAddedEvent, ProductFeeRemovedEvent, ProductNoteAddedEvent, ProductNoteRemovedEvent, CartEventType, CartEventPayload, } from './pubsub/topics/cart/types';
277
266
  export type { PaymentDonePayload, PaymentErrPayload, PaymentDoneEvent, PaymentErrEvent, PaymentsEventType, PaymentsEventPayload, } from './pubsub/topics/payments/types';
267
+ export type { CheckoutStartedPayload, PaymentCompletedPayload, PaymentFailedPayload, CheckoutStartedEvent, PaymentCompletedEvent, PaymentFailedEvent, CheckoutEventType, CheckoutEventPayload, } from './pubsub/topics/checkout/types';
278
268
  export type { SplitPaymentUpdatedPayload, SplitPaymentUpdatedEvent, SplitPaymentsEventType, SplitPaymentsEventPayload, } from './pubsub/topics/split-payments/types';
279
269
  export type { RowCreatedPayload, RowUpdatedPayload, RowDeletedPayload, RowCreatedEvent, RowUpdatedEvent, RowDeletedEvent, CustomTablesEventType, CustomTablesEventPayload, } from './pubsub/topics/custom-tables/types';
280
270
  export type { PrintStartedPayload, PrintCompletedPayload, PrintErrorPayload, PrintStartedEvent, PrintCompletedEvent, PrintErrorEvent, PrintEventType, PrintEventPayload, } from './pubsub/topics/print/types';
package/dist/index.js CHANGED
@@ -1,13 +1,6 @@
1
1
  // Import actions from new folder structure
2
2
  import { exampleFunction } from './actions/example-function/action';
3
3
  import { getProducts } from './actions/get-products/action';
4
- import { getBookingResources } from './actions/get-booking-resources/action';
5
- import { getBookingAvailability } from './actions/get-booking-availability/action';
6
- import { getBookings } from './actions/get-bookings/action';
7
- import { holdBooking } from './actions/hold-booking/action';
8
- import { addBookingToCart } from './actions/add-booking-to-cart/action';
9
- import { removeBookingFromCart } from './actions/remove-booking-from-cart/action';
10
- import { cancelBooking } from './actions/cancel-booking/action';
11
4
  import { addCustomSale } from './actions/add-custom-sale/action';
12
5
  import { editCustomSale } from './actions/edit-custom-sale/action';
13
6
  import { addNonRevenueItem } from './actions/add-non-revenue-item/action';
@@ -50,6 +43,8 @@ import { redeemPayment } from './actions/redeem-payment/action';
50
43
  import { integrationPayment } from './actions/integration-payment/action';
51
44
  import { createPaymentLink } from './actions/create-payment-link/action';
52
45
  import { chargeMoto } from './actions/charge-moto/action';
46
+ import { startCheckout } from './actions/start-checkout/action';
47
+ import { resumeCheckout } from './actions/resume-checkout/action';
53
48
  // Customer Actions
54
49
  import { addCustomerNote } from './actions/add-customer-note/action';
55
50
  import { removeCustomerNote } from './actions/remove-customer-note/action';
@@ -144,13 +139,6 @@ export const command = {
144
139
  exampleFunction,
145
140
  generateAPIKey,
146
141
  getProducts,
147
- getBookingResources,
148
- getBookingAvailability,
149
- getBookings,
150
- holdBooking,
151
- addBookingToCart,
152
- removeBookingFromCart,
153
- cancelBooking,
154
142
  addCustomSale,
155
143
  editCustomSale,
156
144
  addNonRevenueItem,
@@ -194,6 +182,8 @@ export const command = {
194
182
  integrationPayment,
195
183
  createPaymentLink,
196
184
  chargeMoto,
185
+ startCheckout,
186
+ resumeCheckout,
197
187
  // Customer Actions
198
188
  addCustomerNote,
199
189
  removeCustomerNote,
@@ -304,6 +294,7 @@ export { refundsTopic } from './pubsub/topics/refunds';
304
294
  export { productsTopic } from './pubsub/topics/products';
305
295
  export { cartTopic } from './pubsub/topics/cart';
306
296
  export { paymentsTopic } from './pubsub/topics/payments';
297
+ export { checkoutTopic } from './pubsub/topics/checkout';
307
298
  export { splitPaymentsTopic } from './pubsub/topics/split-payments';
308
299
  export { customTablesTopic } from './pubsub/topics/custom-tables';
309
300
  export { printTopic } from './pubsub/topics/print';
@@ -315,7 +306,6 @@ export { variantsTopic } from './pubsub/topics/variants';
315
306
  export { transactionsTopic } from './pubsub/topics/transactions';
316
307
  export { categoriesTopic } from './pubsub/topics/categories';
317
308
  export { attributesTopic } from './pubsub/topics/attributes';
318
- export { bookingsTopic } from './pubsub/topics/bookings';
319
309
  // Export Custom Tables Types
320
310
  export { AttributeType } from './common-types/attribute-type';
321
311
  // State Machine Fragments
@@ -31,6 +31,8 @@ import { mockCashPayment } from '../../actions/cash-payment/mock';
31
31
  import { mockGetCashRoundingAmount } from '../../actions/get-cash-rounding-amount/mock';
32
32
  import { mockCreatePaymentLink } from '../../actions/create-payment-link/mock';
33
33
  import { mockChargeMoto } from '../../actions/charge-moto/mock';
34
+ import { mockStartCheckout } from '../../actions/start-checkout/mock';
35
+ import { mockResumeCheckout } from '../../actions/resume-checkout/mock';
34
36
  import { mockGetTimeClockStatus } from '../../actions/get-time-clock-status/mock';
35
37
  import { mockClearCart } from '../../actions/clear-cart/mock';
36
38
  import { mockDeleteParkedOrder } from '../../actions/delete-parked-order/mock';
@@ -42,13 +44,6 @@ import { mockGetCurrentCart } from '../../actions/get-current-cart/mock';
42
44
  import { mockGetCustomers } from '../../actions/get-customers/mock';
43
45
  import { mockGetOrders } from '../../actions/get-orders/mock';
44
46
  import { mockGetProducts } from '../../actions/get-products/mock';
45
- import { mockGetBookingResources } from '../../actions/get-booking-resources/mock';
46
- import { mockGetBookingAvailability } from '../../actions/get-booking-availability/mock';
47
- import { mockGetBookings } from '../../actions/get-bookings/mock';
48
- import { mockHoldBooking } from '../../actions/hold-booking/mock';
49
- import { mockAddBookingToCart } from '../../actions/add-booking-to-cart/mock';
50
- import { mockRemoveBookingFromCart } from '../../actions/remove-booking-from-cart/mock';
51
- import { mockCancelBooking } from '../../actions/cancel-booking/mock';
52
47
  import { mockGetRefunds } from '../../actions/get-refunds/mock';
53
48
  import { mockGetTaxTables } from '../../actions/get-tax-tables/mock';
54
49
  import { mockGetRemainingRefundableQuantities } from '../../actions/get-remaining-refundable-quantities/mock';
@@ -135,6 +130,8 @@ export const RENDER_MOCKS = {
135
130
  getCashRoundingAmount: mockGetCashRoundingAmount,
136
131
  createPaymentLink: mockCreatePaymentLink,
137
132
  chargeMoto: mockChargeMoto,
133
+ startCheckout: mockStartCheckout,
134
+ resumeCheckout: mockResumeCheckout,
138
135
  clearCart: mockClearCart,
139
136
  deleteParkedOrder: mockDeleteParkedOrder,
140
137
  voidOrder: mockVoidOrder,
@@ -145,13 +142,6 @@ export const RENDER_MOCKS = {
145
142
  getCustomers: mockGetCustomers,
146
143
  getOrders: mockGetOrders,
147
144
  getProducts: mockGetProducts,
148
- getBookingResources: mockGetBookingResources,
149
- getBookingAvailability: mockGetBookingAvailability,
150
- getBookings: mockGetBookings,
151
- holdBooking: mockHoldBooking,
152
- addBookingToCart: mockAddBookingToCart,
153
- removeBookingFromCart: mockRemoveBookingFromCart,
154
- cancelBooking: mockCancelBooking,
155
145
  getRefunds: mockGetRefunds,
156
146
  getTaxTables: mockGetTaxTables,
157
147
  getRemainingRefundableQuantities: mockGetRemainingRefundableQuantities,
@@ -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, GetBookingResources, GetBookingAvailability, GetBookings, HoldBooking, AddBookingToCart, RemoveBookingFromCart, CancelBooking, CreatePaymentLink, ChargeMoto, GetTimeClockStatus } from '../../index';
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, ResumeCheckout, 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,18 @@ 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;
52
+ /**
53
+ * The RETURN LEG of an online checkout, after a redirect payment method or
54
+ * 3-D Secure sent the shopper away and back. Storefront-only, like
55
+ * `startCheckout`, and safe to call on every page load.
56
+ */
57
+ resumeCheckout: ResumeCheckout;
53
58
  addNonRevenueItem: AddNonRevenueItem;
54
59
  addCustomerNote: AddCustomerNote;
55
60
  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,7 @@
1
+ /**
2
+ * Checkout Topic Definition
3
+ * Defines the checkout topic and its available event types
4
+ */
5
+ import type { TopicDefinition } from "../../types";
6
+ export declare const checkoutTopic: TopicDefinition;
7
+ export * from "./types";
@@ -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,31 @@
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
+ * OPAQUE PROOF OF THIS PAYMENT, handed to the browser by the provider and to
17
+ * nobody else. Pass it to the order-status read and the server verifies it
18
+ * with the provider before believing a word of it.
19
+ *
20
+ * It is the only evidence of an outcome that exists outside the provider's
21
+ * webhook, so it is what recovers an order whose confirmation never arrived.
22
+ * Treat it as a credential: do not log it, do not put it in a URL you share.
23
+ *
24
+ * Absent when the provider reported no payment (see `resultCode`).
25
+ */
26
+ sessionResult?: string;
27
+ }
28
+ /**
29
+ * Typed event for payment-completed
30
+ */
31
+ 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";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checkout Topic Types
3
+ * Aggregated types for all online-checkout events
4
+ */
5
+ // Re-export all event types
6
+ export * from "./checkout-started/types";
7
+ export * from "./payment-completed/types";
8
+ export * from "./payment-failed/types";
@@ -2,20 +2,20 @@
2
2
  * Pub/Sub Topics
3
3
  * Export all available topics and their types
4
4
  */
5
- export * from './customers';
6
- export * from './orders';
7
- export * from './bookings';
8
- export * from './refunds';
9
- export * from './products';
10
- export * from './cart';
11
- export * from './payments';
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';
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 './customers';
6
- export * from './orders';
7
- export * from './bookings';
8
- export * from './refunds';
9
- export * from './products';
10
- export * from './cart';
11
- export * from './payments';
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';
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";