@wix/headless-bookings 0.0.118 → 1.0.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.
Files changed (93) hide show
  1. package/cjs/dist/__mocks__/booking/booking-mocks.d.ts +1 -1
  2. package/cjs/dist/__mocks__/services/services-mocks.d.ts +23 -0
  3. package/cjs/dist/__mocks__/services/services-mocks.js +65 -1
  4. package/cjs/dist/api/calculate-cart/index.d.ts +3 -0
  5. package/cjs/dist/api/calculate-cart/index.js +7 -0
  6. package/cjs/dist/api/create-cart/index.d.ts +3 -0
  7. package/cjs/dist/api/create-cart/index.js +10 -0
  8. package/cjs/dist/api/index.d.ts +3 -9
  9. package/cjs/dist/api/index.js +12 -17
  10. package/cjs/dist/api/place-order/index.d.ts +3 -0
  11. package/cjs/dist/api/place-order/index.js +7 -0
  12. package/cjs/dist/api/query-services/index.js +2 -2
  13. package/cjs/dist/react/booking/Book.js +1 -1
  14. package/cjs/dist/react/core/booking/Book.d.ts +1 -1
  15. package/cjs/dist/react/core/booking/Book.js +1 -1
  16. package/cjs/dist/react/core/booking/Booking.d.ts +1 -1
  17. package/cjs/dist/react/core/booking/Booking.js +14 -5
  18. package/cjs/dist/react/core/location/Location.d.ts +1 -1
  19. package/cjs/dist/react/core/location/Location.js +5 -5
  20. package/cjs/dist/react/core/service/Service.d.ts +10 -1
  21. package/cjs/dist/react/core/service/Service.js +5 -4
  22. package/cjs/dist/react/service/Service.d.ts +68 -1
  23. package/cjs/dist/react/service/Service.js +81 -1
  24. package/cjs/dist/services/booking/book-action/bookAction.d.ts +0 -22
  25. package/cjs/dist/services/booking/book-action/bookAction.js +20 -39
  26. package/cjs/dist/services/booking/book-action/buildCartRequest.d.ts +10 -0
  27. package/cjs/dist/services/booking/book-action/buildCartRequest.js +37 -0
  28. package/cjs/dist/services/booking/book-action/index.d.ts +1 -1
  29. package/cjs/dist/services/booking/book-action/index.js +3 -3
  30. package/cjs/dist/services/booking/book-action/isCheckoutRequired.d.ts +3 -19
  31. package/cjs/dist/services/booking/book-action/isCheckoutRequired.js +11 -29
  32. package/cjs/dist/services/booking/book-action/types.d.ts +1 -1
  33. package/cjs/dist/services/booking/booking.d.ts +1 -1
  34. package/cjs/dist/services/index.d.ts +1 -1
  35. package/cjs/dist/services/index.js +2 -2
  36. package/cjs/dist/services/location-list/location-list.def.d.ts +1 -1
  37. package/cjs/dist/services/location-list/location-list.def.js +1 -1
  38. package/cjs/dist/services/location-list/location-list.js +7 -7
  39. package/cjs/dist/utils/navigation.d.ts +2 -2
  40. package/cjs/dist/utils/navigation.js +2 -2
  41. package/dist/__mocks__/booking/booking-mocks.d.ts +1 -1
  42. package/dist/__mocks__/services/services-mocks.d.ts +23 -0
  43. package/dist/__mocks__/services/services-mocks.js +64 -0
  44. package/dist/api/calculate-cart/index.d.ts +3 -0
  45. package/dist/api/calculate-cart/index.js +4 -0
  46. package/dist/api/create-cart/index.d.ts +3 -0
  47. package/dist/api/create-cart/index.js +5 -0
  48. package/dist/api/index.d.ts +3 -9
  49. package/dist/api/index.js +3 -9
  50. package/dist/api/place-order/index.d.ts +3 -0
  51. package/dist/api/place-order/index.js +4 -0
  52. package/dist/api/query-services/index.js +1 -1
  53. package/dist/react/booking/Book.js +1 -1
  54. package/dist/react/core/booking/Book.d.ts +1 -1
  55. package/dist/react/core/booking/Book.js +1 -1
  56. package/dist/react/core/booking/Booking.d.ts +1 -1
  57. package/dist/react/core/booking/Booking.js +14 -5
  58. package/dist/react/core/location/Location.d.ts +1 -1
  59. package/dist/react/core/location/Location.js +1 -1
  60. package/dist/react/core/service/Service.d.ts +10 -1
  61. package/dist/react/core/service/Service.js +5 -4
  62. package/dist/react/service/Service.d.ts +68 -1
  63. package/dist/react/service/Service.js +81 -1
  64. package/dist/services/booking/book-action/bookAction.d.ts +0 -22
  65. package/dist/services/booking/book-action/bookAction.js +20 -39
  66. package/dist/services/booking/book-action/buildCartRequest.d.ts +10 -0
  67. package/dist/services/booking/book-action/buildCartRequest.js +34 -0
  68. package/dist/services/booking/book-action/index.d.ts +1 -1
  69. package/dist/services/booking/book-action/index.js +1 -1
  70. package/dist/services/booking/book-action/isCheckoutRequired.d.ts +3 -19
  71. package/dist/services/booking/book-action/isCheckoutRequired.js +11 -29
  72. package/dist/services/booking/book-action/types.d.ts +1 -1
  73. package/dist/services/booking/booking.d.ts +1 -1
  74. package/dist/services/index.d.ts +1 -1
  75. package/dist/services/index.js +1 -1
  76. package/dist/services/location-list/location-list.def.d.ts +1 -1
  77. package/dist/services/location-list/location-list.def.js +1 -1
  78. package/dist/services/location-list/location-list.js +1 -1
  79. package/dist/utils/navigation.d.ts +2 -2
  80. package/dist/utils/navigation.js +2 -2
  81. package/package.json +5 -4
  82. package/cjs/dist/api/create-checkout/index.d.ts +0 -40
  83. package/cjs/dist/api/create-checkout/index.js +0 -42
  84. package/cjs/dist/api/create-order/index.d.ts +0 -20
  85. package/cjs/dist/api/create-order/index.js +0 -24
  86. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.d.ts +0 -28
  87. package/cjs/dist/services/booking/book-action/buildCheckoutRequest.js +0 -65
  88. package/dist/api/create-checkout/index.d.ts +0 -40
  89. package/dist/api/create-checkout/index.js +0 -37
  90. package/dist/api/create-order/index.d.ts +0 -20
  91. package/dist/api/create-order/index.js +0 -21
  92. package/dist/services/booking/book-action/buildCheckoutRequest.d.ts +0 -28
  93. package/dist/services/booking/book-action/buildCheckoutRequest.js +0 -62
@@ -1,38 +1,16 @@
1
1
  "use strict";
2
- /**
3
- * Book Action - Orchestrates the booking flow
4
- *
5
- * 1. Validates booking data with canBook()
6
- * 2. Creates a booking via createBooking() from API layer
7
- * 3. Creates a checkout via createCheckout() from API layer
8
- * 4. Determines if checkout is required or can be skipped
9
- * 5. Returns appropriate result for navigation
10
- */
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.executeBookAction = executeBookAction;
13
4
  const index_js_1 = require("../../../api/create-booking/index.js");
14
- const index_js_2 = require("../../../api/create-checkout/index.js");
15
- const index_js_3 = require("../../../api/create-order/index.js");
5
+ const index_js_2 = require("../../../api/create-cart/index.js");
6
+ const index_js_3 = require("../../../api/calculate-cart/index.js");
7
+ const index_js_4 = require("../../../api/place-order/index.js");
16
8
  const buildBookingRequest_js_1 = require("./buildBookingRequest.js");
17
- const buildCheckoutRequest_js_1 = require("./buildCheckoutRequest.js");
9
+ const buildCartRequest_js_1 = require("./buildCartRequest.js");
18
10
  const canBook_js_1 = require("./canBook.js");
19
11
  const isCheckoutRequired_js_1 = require("./isCheckoutRequired.js");
20
12
  const types_js_1 = require("./types.js");
21
- /**
22
- * Executes the complete booking flow:
23
- * 1. Validates that all required data is present
24
- * 2. Creates a booking with the selected service, time slot, and form data
25
- * 3. Creates a checkout session for payment (includes contact details from booking)
26
- * 4. Determines if checkout page is required or can be skipped
27
- * 5. If checkout can be skipped (free/offline), creates order directly
28
- * 6. Returns appropriate result for navigation
29
- *
30
- * @param params - The booking action parameters
31
- * @returns BookResult with either checkoutId or orderId
32
- * @throws Error if validation fails, or booking/checkout/order creation fails
33
- */
34
13
  async function executeBookAction(params) {
35
- // Step 0: Validate
36
14
  if (!(0, canBook_js_1.canBook)({
37
15
  serviceSelections: params.serviceSelections,
38
16
  formSubmission: params.formSubmission,
@@ -51,34 +29,37 @@ async function executeBookAction(params) {
51
29
  if (!bookingId) {
52
30
  throw new Error('Failed to create booking');
53
31
  }
54
- // Step 2: Create checkout
55
- // businessLocationId: prefer timeSlot.location, fallback to global location
32
+ // Step 2: Create cart
56
33
  const firstSelection = params.serviceSelections[0];
57
34
  if (!firstSelection) {
58
35
  throw new Error('No service selection found');
59
36
  }
60
37
  const businessLocationId = firstSelection.timeSlot?.location?._id ?? undefined;
61
- const checkoutRequest = (0, buildCheckoutRequest_js_1.buildCheckoutRequest)({
38
+ const cartRequest = (0, buildCartRequest_js_1.buildCartRequest)({
62
39
  bookingId,
63
40
  contactDetails,
64
41
  businessLocationId,
65
42
  appId: params.appId,
66
43
  });
67
- const checkoutResponse = await (0, index_js_2.createCheckout)(checkoutRequest);
68
- const checkout = checkoutResponse.checkout;
69
- if (!checkout?._id) {
70
- throw new Error('Failed to create checkout');
44
+ const cart = await (0, index_js_2.createCart)(cartRequest);
45
+ if (!cart._id) {
46
+ throw new Error('Failed to create cart');
71
47
  }
72
- // Step 3: Determine if checkout is required or can be skipped
48
+ // Step 3: Calculate cart to get totals (not stored on Cart V2 entity)
49
+ const { cart: calculatedCart, summary } = await (0, index_js_3.calculateCart)(cart._id);
50
+ if (!calculatedCart || !summary) {
51
+ throw new Error('Failed to calculate cart');
52
+ }
53
+ // Step 4: Determine if checkout is required or can be skipped
73
54
  const service = firstSelection.service;
74
- if ((0, isCheckoutRequired_js_1.isCheckoutRequired)(checkout, service)) {
75
- return { type: types_js_1.BookResultType.CheckoutRequired, checkoutId: checkout._id };
55
+ if ((0, isCheckoutRequired_js_1.isCheckoutRequired)(calculatedCart, summary, service)) {
56
+ return { type: types_js_1.BookResultType.CheckoutRequired, cartId: cart._id };
76
57
  }
77
- // Step 4: Skip checkout - create order directly
78
- const orderResponse = await (0, index_js_3.createOrder)(checkout._id);
58
+ // Step 5: Skip checkout — place order directly
59
+ const orderResponse = await (0, index_js_4.placeOrder)(cart._id);
79
60
  const orderId = orderResponse.orderId;
80
61
  if (!orderId) {
81
- throw new Error('Failed to create order');
62
+ throw new Error('Failed to place order');
82
63
  }
83
64
  return { type: types_js_1.BookResultType.CheckoutSkipped, orderId };
84
65
  }
@@ -0,0 +1,10 @@
1
+ import { type CreateCartOptions } from '../../../api/create-cart/index.js';
2
+ import type { ContactDetails } from '../../../api/create-booking/index.js';
3
+ export interface BuildCartParams {
4
+ bookingId: string;
5
+ contactDetails?: ContactDetails;
6
+ businessLocationId?: string;
7
+ /** Optional app ID override for the catalog reference. Defaults to BOOKING_APP_ID. */
8
+ appId?: string;
9
+ }
10
+ export declare function buildCartRequest(params: BuildCartParams): CreateCartOptions;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCartRequest = buildCartRequest;
4
+ const index_js_1 = require("../../../api/create-cart/index.js");
5
+ const constants_js_1 = require("../../constants.js");
6
+ function buildCartRequest(params) {
7
+ const { bookingId, contactDetails, businessLocationId, appId } = params;
8
+ const cart = {
9
+ source: { channelType: index_js_1.ChannelType.WEB },
10
+ };
11
+ if (businessLocationId) {
12
+ cart.businessInfo = { locationId: businessLocationId };
13
+ }
14
+ if (contactDetails) {
15
+ cart.customerInfo = {
16
+ ...(contactDetails.email ? { email: contactDetails.email } : {}),
17
+ };
18
+ if (contactDetails.fullAddress?.country) {
19
+ cart.deliveryInfo = { address: { ...contactDetails.fullAddress } };
20
+ cart.paymentInfo = {
21
+ billingAddress: { ...contactDetails.fullAddress },
22
+ };
23
+ }
24
+ }
25
+ return {
26
+ catalogItems: [
27
+ {
28
+ quantity: 1,
29
+ catalogReference: {
30
+ catalogItemId: bookingId,
31
+ appId: appId ?? constants_js_1.BOOKING_APP_ID,
32
+ },
33
+ },
34
+ ],
35
+ cart,
36
+ };
37
+ }
@@ -4,6 +4,6 @@
4
4
  export { executeBookAction } from './bookAction.js';
5
5
  export { canBook, type CanBookParams } from './canBook.js';
6
6
  export { buildBookingRequest } from './buildBookingRequest.js';
7
- export { buildCheckoutRequest, type BuildCheckoutParams, } from './buildCheckoutRequest.js';
7
+ export { buildCartRequest, type BuildCartParams } from './buildCartRequest.js';
8
8
  export { isCheckoutRequired } from './isCheckoutRequired.js';
9
9
  export { BookResultType, type BookProps, type BookResult, type BookingError, type BookActionParams, type BookChildProps, } from './types.js';
@@ -3,15 +3,15 @@
3
3
  * Book Action - Exports
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BookResultType = exports.isCheckoutRequired = exports.buildCheckoutRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = void 0;
6
+ exports.BookResultType = exports.isCheckoutRequired = exports.buildCartRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = void 0;
7
7
  var bookAction_js_1 = require("./bookAction.js");
8
8
  Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: function () { return bookAction_js_1.executeBookAction; } });
9
9
  var canBook_js_1 = require("./canBook.js");
10
10
  Object.defineProperty(exports, "canBook", { enumerable: true, get: function () { return canBook_js_1.canBook; } });
11
11
  var buildBookingRequest_js_1 = require("./buildBookingRequest.js");
12
12
  Object.defineProperty(exports, "buildBookingRequest", { enumerable: true, get: function () { return buildBookingRequest_js_1.buildBookingRequest; } });
13
- var buildCheckoutRequest_js_1 = require("./buildCheckoutRequest.js");
14
- Object.defineProperty(exports, "buildCheckoutRequest", { enumerable: true, get: function () { return buildCheckoutRequest_js_1.buildCheckoutRequest; } });
13
+ var buildCartRequest_js_1 = require("./buildCartRequest.js");
14
+ Object.defineProperty(exports, "buildCartRequest", { enumerable: true, get: function () { return buildCartRequest_js_1.buildCartRequest; } });
15
15
  var isCheckoutRequired_js_1 = require("./isCheckoutRequired.js");
16
16
  Object.defineProperty(exports, "isCheckoutRequired", { enumerable: true, get: function () { return isCheckoutRequired_js_1.isCheckoutRequired; } });
17
17
  var types_js_1 = require("./types.js");
@@ -1,20 +1,4 @@
1
- /**
2
- * Determines if checkout page is required based on payment amounts
3
- */
4
- import type { Checkout } from '@wix/auto_sdk_ecom_checkout';
1
+ import type { Cart } from '../../../api/create-cart/index.js';
2
+ import type { CartSummary } from '../../../api/calculate-cart/index.js';
5
3
  import type { Service } from '@wix/auto_sdk_bookings_services';
6
- /**
7
- * Determines if checkout page is required based on payment amounts.
8
- *
9
- * Skip checkout when:
10
- * - Free booking: payNow = 0 AND payLater = 0
11
- * - Offline payment: payNow = 0
12
- *
13
- * Force checkout when:
14
- * - Service has cancellation fee policy
15
- *
16
- * @param checkout - The checkout response from createCheckout
17
- * @param service - The service being booked
18
- * @returns true if checkout page is required, false if can skip to order
19
- */
20
- export declare function isCheckoutRequired(checkout: Checkout, service: Service): boolean;
4
+ export declare function isCheckoutRequired(cart: Cart, summary: CartSummary, service: Service): boolean;
@@ -1,35 +1,17 @@
1
1
  "use strict";
2
- /**
3
- * Determines if checkout page is required based on payment amounts
4
- */
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.isCheckoutRequired = isCheckoutRequired;
7
- /**
8
- * Determines if checkout page is required based on payment amounts.
9
- *
10
- * Skip checkout when:
11
- * - Free booking: payNow = 0 AND payLater = 0
12
- * - Offline payment: payNow = 0
13
- *
14
- * Force checkout when:
15
- * - Service has cancellation fee policy
16
- *
17
- * @param checkout - The checkout response from createCheckout
18
- * @param service - The service being booked
19
- * @returns true if checkout page is required, false if can skip to order
20
- */
21
- function isCheckoutRequired(checkout, service) {
22
- // Force checkout for cancellation fee policy
23
- const hasCancellationFee = service.bookingPolicy?.cancellationFeePolicy?.enabled;
24
- if (hasCancellationFee) {
4
+ function isCheckoutRequired(cart, summary, service) {
5
+ if (service.bookingPolicy?.cancellationFeePolicy?.enabled) {
25
6
  return true;
26
7
  }
27
- const payNowAmount = Number(checkout.payNow?.total?.amount ?? 0);
28
- const payLaterAmount = Number(checkout.payLater?.total?.amount ?? 0);
29
- // Free or price plan: both amounts are 0
30
- const isFreeOrPricePlan = payNowAmount === 0 && payLaterAmount === 0;
31
- // Offline payment: payNow is 0
32
- const isOfflinePayment = payNowAmount === 0;
33
- // Skip checkout if free/price plan OR offline payment
34
- return !(isFreeOrPricePlan || isOfflinePayment);
8
+ const total = Number(summary.priceSummary?.total?.amount ?? 0);
9
+ if (total === 0) {
10
+ return false;
11
+ }
12
+ const paymentOption = cart.lineItems?.[0]?.paymentConfig?.paymentOption;
13
+ if (paymentOption === 'FULL_PAYMENT_OFFLINE') {
14
+ return false;
15
+ }
16
+ return true;
35
17
  }
@@ -16,7 +16,7 @@ export declare enum BookResultType {
16
16
  */
17
17
  export type BookResult = {
18
18
  type: BookResultType.CheckoutRequired;
19
- checkoutId: string;
19
+ cartId: string;
20
20
  } | {
21
21
  type: BookResultType.CheckoutSkipped;
22
22
  orderId: string;
@@ -4,7 +4,7 @@
4
4
  * Persists across page navigation in SPA until page refresh
5
5
  */
6
6
  import { type Signal } from '@wix/services-definitions/core-services/signals';
7
- import type { Service, Location as ServiceLocationType } from '@wix/auto_sdk_bookings_services';
7
+ import type { Service, V2Location as ServiceLocationType } from '@wix/auto_sdk_bookings_services';
8
8
  import type { Resource, EventInfo, Location as TimeSlotLocationType } from '@wix/auto_sdk_bookings_availability-time-slots';
9
9
  import type { FormValues } from '@wix/forms/components';
10
10
  import type { BookResult } from './book-action/types.js';
@@ -7,7 +7,7 @@ export { BookingService, BookingServiceDefinition, type BookingServiceConfig, ty
7
7
  export { TimeSlotListService, TimeSlotListServiceDefinition, TimeSlotService, TimeSlotServiceDefinition, ViewMode, loadTimeSlotListConfig, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type TimeSlotServiceAPI, type TimeSlotServiceConfig, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list/index.js';
8
8
  export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
9
9
  export { SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from '../api/query-services/index.js';
10
- export { executeBookAction, canBook, buildBookingRequest, buildCheckoutRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCheckoutParams, } from './booking/book-action/index.js';
10
+ export { executeBookAction, canBook, buildBookingRequest, buildCartRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCartParams, } from './booking/book-action/index.js';
11
11
  export { BookingFormService, BookingFormServiceDefinition, type BookingFormServiceAPI, type BookingFormServiceConfig, } from './booking-form/booking-form.js';
12
12
  export { PaymentService, PaymentServiceDefinition, type PaymentServiceAPI, type PaymentServiceConfig, type PaymentDetails, type PricingServiceSelection, type LineItemAdditionalInfo, type ServicePaymentOptions, loadPaymentConfig, type SuccessPaymentConfigResult, type ErrorPaymentConfigResult, } from './payment/payment.js';
13
13
  export { LocationListService, LocationListServiceDefinition, LocationType, loadLocationListServiceInitialData, locationListServiceBinding, type LocationListServiceAPI, type LocationListServiceConfig, type LocationListActions, type Location, type LoadLocationListServiceResult, getLocationById, } from './location-list/location-list.js';
@@ -4,7 +4,7 @@
4
4
  * Main export file for all service definitions and implementations
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.staffMemberListServiceBinding = exports.loadStaffMemberListServiceInitialData = exports.StaffMemberListServiceDefinition = exports.StaffMemberListService = exports.getLocationById = exports.locationListServiceBinding = exports.loadLocationListServiceInitialData = exports.LocationType = exports.LocationListServiceDefinition = exports.LocationListService = exports.loadPaymentConfig = exports.PaymentServiceDefinition = exports.PaymentService = exports.BookingFormServiceDefinition = exports.BookingFormService = exports.buildCheckoutRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.loadServiceListServiceInitialData = exports.ServiceListServiceDefinition = exports.ServiceListService = exports.loadTimeSlotListConfig = exports.ViewMode = exports.TimeSlotServiceDefinition = exports.TimeSlotService = exports.TimeSlotListServiceDefinition = exports.TimeSlotListService = exports.BookingServiceDefinition = exports.BookingService = exports.loadServiceServiceInitialData = exports.ServiceServiceDefinition = exports.ServiceService = void 0;
7
+ exports.staffMemberListServiceBinding = exports.loadStaffMemberListServiceInitialData = exports.StaffMemberListServiceDefinition = exports.StaffMemberListService = exports.getLocationById = exports.locationListServiceBinding = exports.loadLocationListServiceInitialData = exports.LocationType = exports.LocationListServiceDefinition = exports.LocationListService = exports.loadPaymentConfig = exports.PaymentServiceDefinition = exports.PaymentService = exports.BookingFormServiceDefinition = exports.BookingFormService = exports.buildCartRequest = exports.buildBookingRequest = exports.canBook = exports.executeBookAction = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.loadServiceListServiceInitialData = exports.ServiceListServiceDefinition = exports.ServiceListService = exports.loadTimeSlotListConfig = exports.ViewMode = exports.TimeSlotServiceDefinition = exports.TimeSlotService = exports.TimeSlotListServiceDefinition = exports.TimeSlotListService = exports.BookingServiceDefinition = exports.BookingService = exports.loadServiceServiceInitialData = exports.ServiceServiceDefinition = exports.ServiceService = void 0;
8
8
  var service_js_1 = require("./service/service.js");
9
9
  Object.defineProperty(exports, "ServiceService", { enumerable: true, get: function () { return service_js_1.ServiceService; } });
10
10
  Object.defineProperty(exports, "ServiceServiceDefinition", { enumerable: true, get: function () { return service_js_1.ServiceServiceDefinition; } });
@@ -30,7 +30,7 @@ var index_js_3 = require("./booking/book-action/index.js");
30
30
  Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: function () { return index_js_3.executeBookAction; } });
31
31
  Object.defineProperty(exports, "canBook", { enumerable: true, get: function () { return index_js_3.canBook; } });
32
32
  Object.defineProperty(exports, "buildBookingRequest", { enumerable: true, get: function () { return index_js_3.buildBookingRequest; } });
33
- Object.defineProperty(exports, "buildCheckoutRequest", { enumerable: true, get: function () { return index_js_3.buildCheckoutRequest; } });
33
+ Object.defineProperty(exports, "buildCartRequest", { enumerable: true, get: function () { return index_js_3.buildCartRequest; } });
34
34
  var booking_form_js_1 = require("./booking-form/booking-form.js");
35
35
  Object.defineProperty(exports, "BookingFormService", { enumerable: true, get: function () { return booking_form_js_1.BookingFormService; } });
36
36
  Object.defineProperty(exports, "BookingFormServiceDefinition", { enumerable: true, get: function () { return booking_form_js_1.BookingFormServiceDefinition; } });
@@ -5,7 +5,7 @@
5
5
  * @module Services/LocationList/Definition
6
6
  */
7
7
  import type { Signal, ReadOnlySignal } from '@wix/services-definitions/core-services/signals';
8
- import { LocationType, type Service } from '@wix/auto_sdk_bookings_services';
8
+ import { LocationTypeEnumLocationType as LocationType, type Service } from '@wix/auto_sdk_bookings_services';
9
9
  /**
10
10
  * Location type from the SDK
11
11
  * Represents a service location (BUSINESS, CUSTOM, or CUSTOMER type)
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.LocationType = exports.LocationListServiceDefinition = void 0;
10
10
  const services_definitions_1 = require("@wix/services-definitions");
11
11
  const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
12
- Object.defineProperty(exports, "LocationType", { enumerable: true, get: function () { return auto_sdk_bookings_services_1.LocationType; } });
12
+ Object.defineProperty(exports, "LocationType", { enumerable: true, get: function () { return auto_sdk_bookings_services_1.LocationTypeEnumLocationType; } });
13
13
  // ============================================================================
14
14
  // Service Definition
15
15
  // ============================================================================
@@ -35,13 +35,13 @@ const SYNTHETIC_CUSTOMER_ID = 'customer';
35
35
  function buildDisplayLocations(locations, hasCustomLocations, hasCustomerLocations) {
36
36
  const displayLocations = [];
37
37
  // 1. Add all BUSINESS locations directly
38
- const businessLocations = locations.filter((loc) => loc.type === auto_sdk_bookings_services_1.LocationType.BUSINESS || loc.type === undefined);
38
+ const businessLocations = locations.filter((loc) => loc.type === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.BUSINESS || loc.type === undefined);
39
39
  for (const loc of businessLocations) {
40
40
  displayLocations.push(loc);
41
41
  }
42
42
  // Check for existing CUSTOM/CUSTOMER in array
43
- const customFromArray = locations.find((loc) => loc.type === auto_sdk_bookings_services_1.LocationType.CUSTOM);
44
- const customerFromArray = locations.find((loc) => loc.type === auto_sdk_bookings_services_1.LocationType.CUSTOMER);
43
+ const customFromArray = locations.find((loc) => loc.type === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOM);
44
+ const customerFromArray = locations.find((loc) => loc.type === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOMER);
45
45
  // 2. Add CUSTOM location (from array, or create placeholder)
46
46
  if (customFromArray) {
47
47
  displayLocations.push(customFromArray);
@@ -49,7 +49,7 @@ function buildDisplayLocations(locations, hasCustomLocations, hasCustomerLocatio
49
49
  else if (hasCustomLocations) {
50
50
  // Placeholder custom location (only from explicit flag, not array)
51
51
  const placeholderCustom = {
52
- type: auto_sdk_bookings_services_1.LocationType.CUSTOM,
52
+ type: auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOM,
53
53
  _id: SYNTHETIC_CUSTOM_ID,
54
54
  };
55
55
  displayLocations.push(placeholderCustom);
@@ -61,7 +61,7 @@ function buildDisplayLocations(locations, hasCustomLocations, hasCustomerLocatio
61
61
  else if (hasCustomerLocations) {
62
62
  // Placeholder customer location (only from explicit flag, not array)
63
63
  const placeholderCustomer = {
64
- type: auto_sdk_bookings_services_1.LocationType.CUSTOMER,
64
+ type: auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOMER,
65
65
  _id: SYNTHETIC_CUSTOMER_ID,
66
66
  };
67
67
  displayLocations.push(placeholderCustomer);
@@ -89,8 +89,8 @@ exports.LocationListService = services_definitions_1.implementService.withConfig
89
89
  // Initialize raw locations signal
90
90
  const locationsSignal = signalsService.signal(config.locations || []);
91
91
  // Auto-detect from array
92
- const hasCustomInArray = (config.locations || []).some((loc) => loc.type === auto_sdk_bookings_services_1.LocationType.CUSTOM);
93
- const hasCustomerInArray = (config.locations || []).some((loc) => loc.type === auto_sdk_bookings_services_1.LocationType.CUSTOMER);
92
+ const hasCustomInArray = (config.locations || []).some((loc) => loc.type === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOM);
93
+ const hasCustomerInArray = (config.locations || []).some((loc) => loc.type === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOMER);
94
94
  // Final flags: explicit config OR auto-detected
95
95
  const hasCustomLocationsSignal = signalsService.computed(() => config.hasCustomLocations ?? hasCustomInArray);
96
96
  const hasCustomerLocationsSignal = signalsService.computed(() => config.hasCustomerLocations ?? hasCustomerInArray);
@@ -1,7 +1,7 @@
1
1
  export interface NavigationInfo {
2
2
  postFlowUrl: string;
3
3
  }
4
- export declare function navigateToCheckout({ checkoutId, navigationInfo, }: {
5
- checkoutId: string;
4
+ export declare function navigateToCheckout({ cartId, navigationInfo, }: {
5
+ cartId: string;
6
6
  navigationInfo: NavigationInfo;
7
7
  }): Promise<void>;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.navigateToCheckout = navigateToCheckout;
4
4
  const redirects_1 = require("@wix/redirects");
5
- async function navigateToCheckout({ checkoutId, navigationInfo, }) {
5
+ async function navigateToCheckout({ cartId, navigationInfo, }) {
6
6
  const { redirectSession } = await redirects_1.redirects.createRedirectSession({
7
- ecomCheckout: { checkoutId },
7
+ ecomCheckout: { checkoutId: cartId },
8
8
  callbacks: {
9
9
  postFlowUrl: navigationInfo.postFlowUrl,
10
10
  },
@@ -1,5 +1,5 @@
1
1
  import type { FormValues } from '@wix/forms/components';
2
- import type { Location } from '@wix/auto_sdk_bookings_services';
2
+ import type { V2Location as Location } from '@wix/auto_sdk_bookings_services';
3
3
  import type { ServiceSelection, ServiceSelectionTimeSlot, ExtendedResource } from '../../services/booking/booking.js';
4
4
  export declare function createMockResource(overrides?: Partial<ExtendedResource>): ExtendedResource;
5
5
  export declare function createMockLocation(overrides?: Partial<Location>): Location;
@@ -35,6 +35,29 @@ export declare const mockServiceCourse: Service;
35
35
  * Mock service without optional fields (minimal)
36
36
  */
37
37
  export declare const mockServiceMinimal: Service;
38
+ /**
39
+ * Mock service driving the fixed-duration path: a single value in
40
+ * `sessionDurations`, no `durationRange`. Drives `Service.DurationInMinutes`;
41
+ * `Service.DurationRange` renders nothing for this shape.
42
+ *
43
+ * `mockService` already carries this shape — this is a renamed copy for
44
+ * tests/examples that want to name the case they're exercising.
45
+ */
46
+ export declare const mockServiceFixedDuration: Service;
47
+ /**
48
+ * Mock service driving the HOUR-unit DurationRange path. Mirrors the server
49
+ * payload shape: empty `sessionDurations`, range pre-computed at
50
+ * `availabilityConstraints.durationRange`. `durationRange` is not yet in the
51
+ * SDK's `AvailabilityConstraints` typing (runtime is ahead of types), so the
52
+ * service object is cast — matches the read-side cast in
53
+ * `core/service/Service.tsx`.
54
+ */
55
+ export declare const mockServiceHourRange: Service;
56
+ /**
57
+ * Mock service driving the DAY-unit DurationRange path. Same server shape as
58
+ * {@link mockServiceHourRange}.
59
+ */
60
+ export declare const mockServiceDayRange: Service;
38
61
  /**
39
62
  * Array of mock services for list tests
40
63
  */
@@ -170,6 +170,70 @@ export const mockServiceMinimal = {
170
170
  name: 'Minimal Service',
171
171
  description: '',
172
172
  };
173
+ /**
174
+ * Mock service driving the fixed-duration path: a single value in
175
+ * `sessionDurations`, no `durationRange`. Drives `Service.DurationInMinutes`;
176
+ * `Service.DurationRange` renders nothing for this shape.
177
+ *
178
+ * `mockService` already carries this shape — this is a renamed copy for
179
+ * tests/examples that want to name the case they're exercising.
180
+ */
181
+ export const mockServiceFixedDuration = {
182
+ ...mockService,
183
+ _id: 'test-service-fixed-duration',
184
+ name: 'Fixed Duration Service',
185
+ schedule: {
186
+ availabilityConstraints: {
187
+ sessionDurations: [60],
188
+ },
189
+ },
190
+ };
191
+ /**
192
+ * Mock service driving the HOUR-unit DurationRange path. Mirrors the server
193
+ * payload shape: empty `sessionDurations`, range pre-computed at
194
+ * `availabilityConstraints.durationRange`. `durationRange` is not yet in the
195
+ * SDK's `AvailabilityConstraints` typing (runtime is ahead of types), so the
196
+ * service object is cast — matches the read-side cast in
197
+ * `core/service/Service.tsx`.
198
+ */
199
+ export const mockServiceHourRange = {
200
+ ...mockService,
201
+ _id: 'test-service-hour-range',
202
+ name: 'Hourly Range Service',
203
+ schedule: {
204
+ availabilityConstraints: {
205
+ sessionDurations: [],
206
+ durationRange: {
207
+ unitType: 'HOUR',
208
+ hourOptions: {
209
+ minDurationInMinutes: 120,
210
+ maxDurationInMinutes: 540,
211
+ },
212
+ },
213
+ },
214
+ },
215
+ };
216
+ /**
217
+ * Mock service driving the DAY-unit DurationRange path. Same server shape as
218
+ * {@link mockServiceHourRange}.
219
+ */
220
+ export const mockServiceDayRange = {
221
+ ...mockService,
222
+ _id: 'test-service-day-range',
223
+ name: 'Daily Range Service',
224
+ schedule: {
225
+ availabilityConstraints: {
226
+ sessionDurations: [],
227
+ durationRange: {
228
+ unitType: 'DAY',
229
+ dayOptions: {
230
+ minDurationInDays: 2,
231
+ maxDurationInDays: 5,
232
+ },
233
+ },
234
+ },
235
+ },
236
+ };
173
237
  /**
174
238
  * Array of mock services for list tests
175
239
  */
@@ -0,0 +1,3 @@
1
+ import { type CalculateCartOptions, type CalculateCartResponse } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export declare function calculateCart(cartId: string, options?: CalculateCartOptions): Promise<CalculateCartResponse>;
3
+ export type { CalculateCartResponse, CartSummary, } from '@wix/auto_sdk_ecom_cart-v-2';
@@ -0,0 +1,4 @@
1
+ import { calculateCart as calculateCartSdk, } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export async function calculateCart(cartId, options) {
3
+ return calculateCartSdk(cartId, options);
4
+ }
@@ -0,0 +1,3 @@
1
+ import { type CreateCartOptions, type Cart } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export declare function createCart(options?: CreateCartOptions): Promise<Cart>;
3
+ export { ChannelType, type CreateCartOptions, type Cart, } from '@wix/auto_sdk_ecom_cart-v-2';
@@ -0,0 +1,5 @@
1
+ import { createCart as createCartSdk, } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export async function createCart(options) {
3
+ return createCartSdk(options);
4
+ }
5
+ export { ChannelType, } from '@wix/auto_sdk_ecom_cart-v-2';
@@ -7,14 +7,8 @@
7
7
  export { getServiceById, getServiceBySlug, queryServices, convertPlatformFilterToApiFilter, type PagingMetadata, type QueryServicesRequest, SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from './query-services/index.js';
8
8
  export { fetchAvailability } from './fetch-availability/index.js';
9
9
  export { createBooking, type CreateBookingOptions, type Booking, type CreateBookingRequest, type CreateBookingResponse, type ParticipantNotification, type ContactDetails, } from './create-booking/index.js';
10
- export { createCheckout, ChannelType, type CreateCheckoutRequest, type CreateCheckoutResponse, } from './create-checkout/index.js';
11
- export { createOrder, type CreateOrderOptions, type CreateOrderResponse, } from './create-order/index.js';
10
+ export { createCart, ChannelType, type CreateCartOptions, type Cart, } from './create-cart/index.js';
11
+ export { calculateCart, type CalculateCartResponse, type CartSummary, } from './calculate-cart/index.js';
12
+ export { placeOrder, type PlaceOrderOptions, type PlaceOrderResponse, } from './place-order/index.js';
12
13
  export { queryLocations, getLocationById, type QueryLocationsResult, type LocationData, } from './query-locations/index.js';
13
14
  export { queryCategories, type QueryCategoriesResult, type Category, } from './query-categories/index.js';
14
- /**
15
- * PagingMetadata includes:
16
- * - limit: Number of items per page
17
- * - offset: Number of items to skip
18
- * - count: Number of items returned in the current page
19
- * - hasNext: Whether there are more services available to load
20
- */
package/dist/api/index.js CHANGED
@@ -7,14 +7,8 @@
7
7
  export { getServiceById, getServiceBySlug, queryServices, convertPlatformFilterToApiFilter, SYNTHETIC_CUSTOM_ID, SYNTHETIC_CUSTOMER_ID, } from './query-services/index.js';
8
8
  export { fetchAvailability } from './fetch-availability/index.js';
9
9
  export { createBooking, } from './create-booking/index.js';
10
- export { createCheckout, ChannelType, } from './create-checkout/index.js';
11
- export { createOrder, } from './create-order/index.js';
10
+ export { createCart, ChannelType, } from './create-cart/index.js';
11
+ export { calculateCart, } from './calculate-cart/index.js';
12
+ export { placeOrder, } from './place-order/index.js';
12
13
  export { queryLocations, getLocationById, } from './query-locations/index.js';
13
14
  export { queryCategories, } from './query-categories/index.js';
14
- /**
15
- * PagingMetadata includes:
16
- * - limit: Number of items per page
17
- * - offset: Number of items to skip
18
- * - count: Number of items returned in the current page
19
- * - hasNext: Whether there are more services available to load
20
- */
@@ -0,0 +1,3 @@
1
+ import { type PlaceOrderOptions, type PlaceOrderResponse } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export declare function placeOrder(cartId: string, options?: PlaceOrderOptions): Promise<PlaceOrderResponse>;
3
+ export type { PlaceOrderOptions, PlaceOrderResponse, } from '@wix/auto_sdk_ecom_cart-v-2';
@@ -0,0 +1,4 @@
1
+ import { placeOrder as placeOrderSdk, } from '@wix/auto_sdk_ecom_cart-v-2';
2
+ export async function placeOrder(cartId, options) {
3
+ return placeOrderSdk(cartId, options);
4
+ }
@@ -2,7 +2,7 @@
2
2
  * Query Services API
3
3
  * Fetches single or multiple services with pagination and sorting
4
4
  */
5
- import { queryServices as queryServicesApi, LocationType, } from '@wix/auto_sdk_bookings_services';
5
+ import { queryServices as queryServicesApi, LocationTypeEnumLocationType as LocationType, } from '@wix/auto_sdk_bookings_services';
6
6
  import { BOOKING_APP_ID } from '../../services/constants.js';
7
7
  /**
8
8
  * Synthetic location ID constants for non-business locations
@@ -60,7 +60,7 @@ export const Book = React.forwardRef((props, ref) => {
60
60
  return (_jsx(CoreBook.Book, { onCheckout: (result) => {
61
61
  // Create navigateToCheckout with checkoutId captured
62
62
  const navigateToCheckout = (options) => navigateToCheckoutUtil({
63
- checkoutId: result.checkoutId,
63
+ cartId: result.cartId,
64
64
  navigationInfo: { postFlowUrl: options.postFlowUrl },
65
65
  });
66
66
  // Return user's callback result so core can await it
@@ -24,7 +24,7 @@ export interface BookProps {
24
24
  * Return a Promise to keep loading state active until it resolves.
25
25
  */
26
26
  onCheckout?: (result: {
27
- checkoutId: string;
27
+ cartId: string;
28
28
  }) => void | Promise<unknown>;
29
29
  /**
30
30
  * Called when booking completes without requiring checkout.
@@ -49,7 +49,7 @@ export function Book(props) {
49
49
  try {
50
50
  const result = await bookingService.actions.book();
51
51
  if (result.type === BookResultType.CheckoutRequired) {
52
- await onCheckout?.({ checkoutId: result.checkoutId });
52
+ await onCheckout?.({ cartId: result.cartId });
53
53
  }
54
54
  else {
55
55
  await onComplete?.({ orderId: result.orderId });
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  import { type BookingServiceConfig, type ServiceSelection, type BookingServiceActions } from '../../../services/booking/booking.js';
7
7
  import type { FormValues } from '@wix/forms/components';
8
8
  import type { TimeSlot, Resource } from '@wix/auto_sdk_bookings_availability-time-slots';
9
- import { type Service, type Location as ServiceLocationType } from '@wix/auto_sdk_bookings_services';
9
+ import { type Service, type V2Location as ServiceLocationType } from '@wix/auto_sdk_bookings_services';
10
10
  import type { PricingServiceSelection } from '../../../services/payment/payment.js';
11
11
  /**
12
12
  * Props for Booking.Root component