@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,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
  */
@@ -3,7 +3,7 @@
3
3
  * Shared mock data for booking service tests
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.mockServiceInPerson = exports.mockServiceWithDeposit = exports.mockSingleStaffMemberListConfig = exports.mockEmptyStaffMemberListConfig = exports.mockStaffMemberListConfig = exports.mockStaffMembers = exports.mockStaffMemberNoName = exports.mockStaffMemberMinimal = exports.mockStaffMember2 = exports.mockStaffMember = exports.mockServiceListConfigWithCategories = exports.mockCategories = exports.mockServiceConfig = exports.mockEmptyServiceListConfig = exports.mockServiceListConfigWithMore = exports.mockServiceListConfig = exports.mockPagingMetadataEmpty = exports.mockPagingMetadataWithMore = exports.mockPagingMetadata = exports.mockServices = exports.mockServiceMinimal = exports.mockServiceCourse = exports.mockServiceClass = exports.mockServiceNoFee = exports.mockServiceCustomPrice = exports.mockServiceVariedPrice = exports.mockService = void 0;
6
+ exports.mockServiceInPerson = exports.mockServiceWithDeposit = exports.mockSingleStaffMemberListConfig = exports.mockEmptyStaffMemberListConfig = exports.mockStaffMemberListConfig = exports.mockStaffMembers = exports.mockStaffMemberNoName = exports.mockStaffMemberMinimal = exports.mockStaffMember2 = exports.mockStaffMember = exports.mockServiceListConfigWithCategories = exports.mockCategories = exports.mockServiceConfig = exports.mockEmptyServiceListConfig = exports.mockServiceListConfigWithMore = exports.mockServiceListConfig = exports.mockPagingMetadataEmpty = exports.mockPagingMetadataWithMore = exports.mockPagingMetadata = exports.mockServices = exports.mockServiceDayRange = exports.mockServiceHourRange = exports.mockServiceFixedDuration = exports.mockServiceMinimal = exports.mockServiceCourse = exports.mockServiceClass = exports.mockServiceNoFee = exports.mockServiceCustomPrice = exports.mockServiceVariedPrice = exports.mockService = void 0;
7
7
  exports.createLargeServiceList = createLargeServiceList;
8
8
  exports.createLargeStaffMemberList = createLargeStaffMemberList;
9
9
  const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
@@ -175,6 +175,70 @@ exports.mockServiceMinimal = {
175
175
  name: 'Minimal Service',
176
176
  description: '',
177
177
  };
178
+ /**
179
+ * Mock service driving the fixed-duration path: a single value in
180
+ * `sessionDurations`, no `durationRange`. Drives `Service.DurationInMinutes`;
181
+ * `Service.DurationRange` renders nothing for this shape.
182
+ *
183
+ * `mockService` already carries this shape — this is a renamed copy for
184
+ * tests/examples that want to name the case they're exercising.
185
+ */
186
+ exports.mockServiceFixedDuration = {
187
+ ...exports.mockService,
188
+ _id: 'test-service-fixed-duration',
189
+ name: 'Fixed Duration Service',
190
+ schedule: {
191
+ availabilityConstraints: {
192
+ sessionDurations: [60],
193
+ },
194
+ },
195
+ };
196
+ /**
197
+ * Mock service driving the HOUR-unit DurationRange path. Mirrors the server
198
+ * payload shape: empty `sessionDurations`, range pre-computed at
199
+ * `availabilityConstraints.durationRange`. `durationRange` is not yet in the
200
+ * SDK's `AvailabilityConstraints` typing (runtime is ahead of types), so the
201
+ * service object is cast — matches the read-side cast in
202
+ * `core/service/Service.tsx`.
203
+ */
204
+ exports.mockServiceHourRange = {
205
+ ...exports.mockService,
206
+ _id: 'test-service-hour-range',
207
+ name: 'Hourly Range Service',
208
+ schedule: {
209
+ availabilityConstraints: {
210
+ sessionDurations: [],
211
+ durationRange: {
212
+ unitType: 'HOUR',
213
+ hourOptions: {
214
+ minDurationInMinutes: 120,
215
+ maxDurationInMinutes: 540,
216
+ },
217
+ },
218
+ },
219
+ },
220
+ };
221
+ /**
222
+ * Mock service driving the DAY-unit DurationRange path. Same server shape as
223
+ * {@link mockServiceHourRange}.
224
+ */
225
+ exports.mockServiceDayRange = {
226
+ ...exports.mockService,
227
+ _id: 'test-service-day-range',
228
+ name: 'Daily Range Service',
229
+ schedule: {
230
+ availabilityConstraints: {
231
+ sessionDurations: [],
232
+ durationRange: {
233
+ unitType: 'DAY',
234
+ dayOptions: {
235
+ minDurationInDays: 2,
236
+ maxDurationInDays: 5,
237
+ },
238
+ },
239
+ },
240
+ },
241
+ };
178
242
  /**
179
243
  * Array of mock services for list tests
180
244
  */
@@ -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,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateCart = calculateCart;
4
+ const auto_sdk_ecom_cart_v_2_1 = require("@wix/auto_sdk_ecom_cart-v-2");
5
+ async function calculateCart(cartId, options) {
6
+ return (0, auto_sdk_ecom_cart_v_2_1.calculateCart)(cartId, options);
7
+ }
@@ -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,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChannelType = void 0;
4
+ exports.createCart = createCart;
5
+ const auto_sdk_ecom_cart_v_2_1 = require("@wix/auto_sdk_ecom_cart-v-2");
6
+ async function createCart(options) {
7
+ return (0, auto_sdk_ecom_cart_v_2_1.createCart)(options);
8
+ }
9
+ var auto_sdk_ecom_cart_v_2_2 = require("@wix/auto_sdk_ecom_cart-v-2");
10
+ Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return auto_sdk_ecom_cart_v_2_2.ChannelType; } });
@@ -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
- */
@@ -6,7 +6,7 @@
6
6
  * @module API
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.queryCategories = exports.getLocationById = exports.queryLocations = exports.createOrder = exports.ChannelType = exports.createCheckout = exports.createBooking = exports.fetchAvailability = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.convertPlatformFilterToApiFilter = exports.queryServices = exports.getServiceBySlug = exports.getServiceById = void 0;
9
+ exports.queryCategories = exports.getLocationById = exports.queryLocations = exports.placeOrder = exports.calculateCart = exports.ChannelType = exports.createCart = exports.createBooking = exports.fetchAvailability = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.convertPlatformFilterToApiFilter = exports.queryServices = exports.getServiceBySlug = exports.getServiceById = void 0;
10
10
  var index_js_1 = require("./query-services/index.js");
11
11
  Object.defineProperty(exports, "getServiceById", { enumerable: true, get: function () { return index_js_1.getServiceById; } });
12
12
  Object.defineProperty(exports, "getServiceBySlug", { enumerable: true, get: function () { return index_js_1.getServiceBySlug; } });
@@ -18,20 +18,15 @@ var index_js_2 = require("./fetch-availability/index.js");
18
18
  Object.defineProperty(exports, "fetchAvailability", { enumerable: true, get: function () { return index_js_2.fetchAvailability; } });
19
19
  var index_js_3 = require("./create-booking/index.js");
20
20
  Object.defineProperty(exports, "createBooking", { enumerable: true, get: function () { return index_js_3.createBooking; } });
21
- var index_js_4 = require("./create-checkout/index.js");
22
- Object.defineProperty(exports, "createCheckout", { enumerable: true, get: function () { return index_js_4.createCheckout; } });
21
+ var index_js_4 = require("./create-cart/index.js");
22
+ Object.defineProperty(exports, "createCart", { enumerable: true, get: function () { return index_js_4.createCart; } });
23
23
  Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return index_js_4.ChannelType; } });
24
- var index_js_5 = require("./create-order/index.js");
25
- Object.defineProperty(exports, "createOrder", { enumerable: true, get: function () { return index_js_5.createOrder; } });
26
- var index_js_6 = require("./query-locations/index.js");
27
- Object.defineProperty(exports, "queryLocations", { enumerable: true, get: function () { return index_js_6.queryLocations; } });
28
- Object.defineProperty(exports, "getLocationById", { enumerable: true, get: function () { return index_js_6.getLocationById; } });
29
- var index_js_7 = require("./query-categories/index.js");
30
- Object.defineProperty(exports, "queryCategories", { enumerable: true, get: function () { return index_js_7.queryCategories; } });
31
- /**
32
- * PagingMetadata includes:
33
- * - limit: Number of items per page
34
- * - offset: Number of items to skip
35
- * - count: Number of items returned in the current page
36
- * - hasNext: Whether there are more services available to load
37
- */
24
+ var index_js_5 = require("./calculate-cart/index.js");
25
+ Object.defineProperty(exports, "calculateCart", { enumerable: true, get: function () { return index_js_5.calculateCart; } });
26
+ var index_js_6 = require("./place-order/index.js");
27
+ Object.defineProperty(exports, "placeOrder", { enumerable: true, get: function () { return index_js_6.placeOrder; } });
28
+ var index_js_7 = require("./query-locations/index.js");
29
+ Object.defineProperty(exports, "queryLocations", { enumerable: true, get: function () { return index_js_7.queryLocations; } });
30
+ Object.defineProperty(exports, "getLocationById", { enumerable: true, get: function () { return index_js_7.getLocationById; } });
31
+ var index_js_8 = require("./query-categories/index.js");
32
+ Object.defineProperty(exports, "queryCategories", { enumerable: true, get: function () { return index_js_8.queryCategories; } });
@@ -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,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.placeOrder = placeOrder;
4
+ const auto_sdk_ecom_cart_v_2_1 = require("@wix/auto_sdk_ecom_cart-v-2");
5
+ async function placeOrder(cartId, options) {
6
+ return (0, auto_sdk_ecom_cart_v_2_1.placeOrder)(cartId, options);
7
+ }
@@ -143,10 +143,10 @@ function convertPlatformFilterToApiFilter(platformFilter) {
143
143
  const businessLocationIds = [];
144
144
  for (const id of locationIds) {
145
145
  if (id === exports.SYNTHETIC_CUSTOM_ID) {
146
- syntheticTypes.push(auto_sdk_bookings_services_1.LocationType.CUSTOM);
146
+ syntheticTypes.push(auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOM);
147
147
  }
148
148
  else if (id === exports.SYNTHETIC_CUSTOMER_ID) {
149
- syntheticTypes.push(auto_sdk_bookings_services_1.LocationType.CUSTOMER);
149
+ syntheticTypes.push(auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOMER);
150
150
  }
151
151
  else {
152
152
  businessLocationIds.push(id);
@@ -99,7 +99,7 @@ exports.Book = react_1.default.forwardRef((props, ref) => {
99
99
  return ((0, jsx_runtime_1.jsx)(CoreBook.Book, { onCheckout: (result) => {
100
100
  // Create navigateToCheckout with checkoutId captured
101
101
  const navigateToCheckout = (options) => (0, navigation_js_1.navigateToCheckout)({
102
- checkoutId: result.checkoutId,
102
+ cartId: result.cartId,
103
103
  navigationInfo: { postFlowUrl: options.postFlowUrl },
104
104
  });
105
105
  // 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.
@@ -52,7 +52,7 @@ function Book(props) {
52
52
  try {
53
53
  const result = await bookingService.actions.book();
54
54
  if (result.type === types_js_1.BookResultType.CheckoutRequired) {
55
- await onCheckout?.({ checkoutId: result.checkoutId });
55
+ await onCheckout?.({ cartId: result.cartId });
56
56
  }
57
57
  else {
58
58
  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
@@ -65,7 +65,16 @@ function Root(props) {
65
65
  function mapTimeSlotLocationToServiceLocation(timeSlotLocation) {
66
66
  // TimeSlot location has flat name/formattedAddress at top level
67
67
  // Convert to nested business/custom structure that CoreLocation expects
68
- const locationType = timeSlotLocation.locationType;
68
+ const isCustomer = timeSlotLocation.locationType === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOMER;
69
+ const isCustom = timeSlotLocation.locationType === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOM;
70
+ // The two SDKs share BUSINESS/CUSTOM/CUSTOMER but the time-slots enum also
71
+ // exposes UNKNOWN_LOCATION_TYPE, which V2Location.type does not accept.
72
+ // Default to BUSINESS for any unrecognized value.
73
+ const type = isCustomer
74
+ ? auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOMER
75
+ : isCustom
76
+ ? auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOM
77
+ : auto_sdk_bookings_services_1.LocationTypeEnumLocationType.BUSINESS;
69
78
  const location = {
70
79
  _id: timeSlotLocation._id ?? undefined,
71
80
  name: timeSlotLocation.name ?? undefined,
@@ -77,10 +86,10 @@ function mapTimeSlotLocationToServiceLocation(timeSlotLocation) {
77
86
  };
78
87
  return {
79
88
  _id: timeSlotLocation._id ?? undefined,
80
- type: locationType,
81
- ...(locationType === auto_sdk_bookings_services_1.LocationType.CUSTOMER
89
+ type,
90
+ ...(isCustomer
82
91
  ? null
83
- : locationType === auto_sdk_bookings_services_1.LocationType.CUSTOM
92
+ : isCustom
84
93
  ? { custom: location }
85
94
  : { business: location }),
86
95
  };
@@ -91,7 +100,7 @@ function mapTimeSlotLocationToServiceLocation(timeSlotLocation) {
91
100
  * 2. If not set, fall back to the first service selection's slot location
92
101
  */
93
102
  function resolveLocation(bookingLocation, serviceSelections) {
94
- if (bookingLocation && bookingLocation.type === auto_sdk_bookings_services_1.LocationType.BUSINESS) {
103
+ if (bookingLocation && bookingLocation.type === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.BUSINESS) {
95
104
  return bookingLocation;
96
105
  }
97
106
  // Fallback to first slot's location
@@ -6,7 +6,7 @@
6
6
  * @module Core/Location
7
7
  */
8
8
  import React from 'react';
9
- import { LocationType } from '@wix/auto_sdk_bookings_services';
9
+ import { LocationTypeEnumLocationType as LocationType } from '@wix/auto_sdk_bookings_services';
10
10
  import type { AddressData as AddressDataType } from '@wix/headless-components/react';
11
11
  import type { Location } from '../../../services/location-list/location-list.def.js';
12
12
  /**
@@ -90,7 +90,7 @@ function hasLocationData(location) {
90
90
  */
91
91
  function parseLocationAddress(location) {
92
92
  // Handle customer location - return null, let consumer handle
93
- if (location.type !== auto_sdk_bookings_services_1.LocationType.BUSINESS) {
93
+ if (location.type !== auto_sdk_bookings_services_1.LocationTypeEnumLocationType.BUSINESS) {
94
94
  return null;
95
95
  }
96
96
  // Get the common address from the appropriate location type
@@ -123,7 +123,7 @@ function parseLocationAddress(location) {
123
123
  * Get location type from location data
124
124
  */
125
125
  function getLocationType(location) {
126
- return location.type || auto_sdk_bookings_services_1.LocationType.BUSINESS;
126
+ return location.type || auto_sdk_bookings_services_1.LocationTypeEnumLocationType.BUSINESS;
127
127
  }
128
128
  /**
129
129
  * Computes LocationRenderProps from location with label fallbacks
@@ -132,7 +132,7 @@ function computeLocationRenderProps(rawLocation, labels) {
132
132
  // Handle no location
133
133
  if (!rawLocation) {
134
134
  return {
135
- locationType: auto_sdk_bookings_services_1.LocationType.BUSINESS,
135
+ locationType: auto_sdk_bookings_services_1.LocationTypeEnumLocationType.BUSINESS,
136
136
  address: null,
137
137
  name: undefined,
138
138
  locationId: undefined,
@@ -146,8 +146,8 @@ function computeLocationRenderProps(rawLocation, labels) {
146
146
  }
147
147
  const locationType = getLocationType(rawLocation);
148
148
  const hasData = hasLocationData(rawLocation);
149
- const isCustomLocation = locationType === auto_sdk_bookings_services_1.LocationType.CUSTOM;
150
- const isCustomerLocation = locationType === auto_sdk_bookings_services_1.LocationType.CUSTOMER;
149
+ const isCustomLocation = locationType === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOM;
150
+ const isCustomerLocation = locationType === auto_sdk_bookings_services_1.LocationTypeEnumLocationType.CUSTOMER;
151
151
  // Compute name with fallback chain:
152
152
  // 1. business.name
153
153
  // 2. custom.address.addressLine
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import React from 'react';
6
6
  import { type ServiceServiceConfig } from '../../../services/service/service.js';
7
- import type { Service, Payment, BookingPolicy, Schedule, StaffMember } from '@wix/auto_sdk_bookings_services';
7
+ import type { Service, Payment, BookingPolicy, Schedule, StaffMember, DurationRange } from '@wix/auto_sdk_bookings_services';
8
8
  import type { MoneyData } from '@wix/headless-components/react';
9
9
  /**
10
10
  * Props for Service.Root component
@@ -50,6 +50,15 @@ export interface InfoProps {
50
50
  description: string;
51
51
  tagline?: string;
52
52
  duration?: number;
53
+ /**
54
+ * Typed range of supported session durations, derived from
55
+ * `service.schedule.availabilityConstraints.sessionDurations`. Set when the
56
+ * service supports two or more distinct durations; otherwise undefined and
57
+ * the single-value `duration` field above should be used. Consumers branch
58
+ * on `range.unitType` (the SDK `UnitType` enum) and read the matching
59
+ * `range.hourOptions` / `range.dayOptions` config.
60
+ */
61
+ durationRange?: DurationRange;
53
62
  type?: string;
54
63
  category?: {
55
64
  name?: string;
@@ -96,9 +96,9 @@ function Info(props) {
96
96
  currency,
97
97
  };
98
98
  }
99
- // Extract duration from schedule.availabilityConstraints.sessionDurations
100
- // Use the first duration if multiple are available
101
- const duration = service.schedule?.availabilityConstraints?.sessionDurations?.[0];
99
+ const constraints = service.schedule?.availabilityConstraints;
100
+ const duration = constraints?.sessionDurations?.[0];
101
+ const durationRange = constraints?.durationRange;
102
102
  // Get staff members from staffMemberDetails.staffMembers
103
103
  // (available when using conditionalFields: ['STAFF_MEMBER_DETAILS'] in queryServices)
104
104
  const staff = service.staffMembers || [];
@@ -128,7 +128,8 @@ function Info(props) {
128
128
  name: service.name || '',
129
129
  description: service.description || '',
130
130
  tagline: service.tagLine || undefined,
131
- duration: duration,
131
+ duration,
132
+ durationRange,
132
133
  type: service.type,
133
134
  category: service.category
134
135
  ? {
@@ -5,7 +5,7 @@
5
5
  import React from 'react';
6
6
  import { AsChildChildren } from '@wix/headless-utils/react';
7
7
  import { MoneyData } from '@wix/headless-components/react';
8
- import { type Service, type Payment } from '@wix/auto_sdk_bookings_services';
8
+ import { type Service, type Payment, type DurationRange as DurationRangeData } from '@wix/auto_sdk_bookings_services';
9
9
  import * as ServiceMediaModule from './ServiceMedia.js';
10
10
  export declare const TestIds: {
11
11
  readonly serviceRoot: "service-root";
@@ -14,6 +14,7 @@ export declare const TestIds: {
14
14
  readonly servicePrice: "service-price";
15
15
  readonly serviceTagline: "service-tagline";
16
16
  readonly serviceDurationInMinutes: "service-duration-in-minutes";
17
+ readonly serviceDurationRange: "service-duration-range";
17
18
  readonly serviceType: "service-type";
18
19
  readonly serviceCategory: "service-category";
19
20
  readonly serviceLocations: "service-locations";
@@ -340,6 +341,72 @@ export interface DurationInMinutesProps extends Omit<React.HTMLAttributes<HTMLEl
340
341
  * ```
341
342
  */
342
343
  export declare const DurationInMinutes: React.ForwardRefExoticComponent<DurationInMinutesProps & React.RefAttributes<HTMLElement>>;
344
+ /**
345
+ * Props for Service DurationRange component
346
+ */
347
+ export interface DurationRangeProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
348
+ asChild?: boolean;
349
+ children?: AsChildChildren<{
350
+ range: DurationRangeData;
351
+ }>;
352
+ }
353
+ /**
354
+ * Provides the service's supported session duration range as raw SDK data.
355
+ * Renders nothing when the service has fewer than two distinct supported
356
+ * durations — use {@link DurationInMinutes} for that case.
357
+ *
358
+ * The component is intentionally UI-agnostic: it does not pick formatting,
359
+ * units, or labels for you. The default render outputs only the raw
360
+ * `min - max` numbers (no unit text). Consumers wanting unit-aware UI use
361
+ * `asChild` with a custom render and narrow on the SDK `range` payload
362
+ * (`range.hourOptions` / `range.dayOptions` / `range.unitType`, or any
363
+ * other unit configuration the SDK adds in the future).
364
+ *
365
+ * @component
366
+ * @example
367
+ * ```tsx
368
+ * // Default usage - displays raw min/max, e.g. "120 - 540" or "2 - 5"
369
+ * <Service.DurationRange className="text-base text-secondary-foreground" />
370
+ * ```
371
+ *
372
+ * @example
373
+ * ```tsx
374
+ * // asChild with primitive element
375
+ * <Service.DurationRange asChild>
376
+ * <span className="font-semibold" />
377
+ * </Service.DurationRange>
378
+ * ```
379
+ *
380
+ * @example
381
+ * ```tsx
382
+ * // asChild with custom component - narrow on the SDK range payload to
383
+ * // decide unit-specific formatting.
384
+ * <Service.DurationRange asChild>
385
+ * {React.forwardRef(({ range, ...props }, ref) => {
386
+ * if (range.hourOptions) {
387
+ * const { minDurationInMinutes: min, maxDurationInMinutes: max } =
388
+ * range.hourOptions;
389
+ * return (
390
+ * <span ref={ref} {...props}>
391
+ * {min}-{max} min
392
+ * </span>
393
+ * );
394
+ * }
395
+ * if (range.dayOptions) {
396
+ * const { minDurationInDays: min, maxDurationInDays: max } =
397
+ * range.dayOptions;
398
+ * return (
399
+ * <span ref={ref} {...props}>
400
+ * {min}-{max} days
401
+ * </span>
402
+ * );
403
+ * }
404
+ * return <span ref={ref} {...props} />;
405
+ * })}
406
+ * </Service.DurationRange>
407
+ * ```
408
+ */
409
+ export declare const DurationRange: React.ForwardRefExoticComponent<DurationRangeProps & React.RefAttributes<HTMLElement>>;
343
410
  /**
344
411
  * Props for Service Type component
345
412
  */
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.CoverMedia = exports.MainMedia = exports.StaffMembers = exports.Locations = exports.AvailableOnline = exports.DefaultCapacity = exports.Schedule = exports.ScheduleSessionDuration = exports.ScheduleLastSessionEnd = exports.ScheduleFirstSessionStart = exports.Policy = exports.PolicyMaxParticipantsPerBooking = exports.PolicyBookAfterStartEnabled = exports.PolicyWaitlistCapacity = exports.PolicyLatestRescheduleInMinutes = exports.PolicyEarliestBookingInMinutes = exports.PolicyLatestBookingInMinutes = exports.PolicyLatestCancellationInMinutes = exports.Actions = exports.Raw = exports.StaffMemberRepeater = exports.StaffMembersList = exports.LocationRepeater = exports.LocationsList = exports.Category = exports.Type = exports.DurationInMinutes = exports.Tagline = exports.Price = exports.Description = exports.Name = exports.Root = exports.TestIds = void 0;
39
+ exports.CoverMedia = exports.MainMedia = exports.StaffMembers = exports.Locations = exports.AvailableOnline = exports.DefaultCapacity = exports.Schedule = exports.ScheduleSessionDuration = exports.ScheduleLastSessionEnd = exports.ScheduleFirstSessionStart = exports.Policy = exports.PolicyMaxParticipantsPerBooking = exports.PolicyBookAfterStartEnabled = exports.PolicyWaitlistCapacity = exports.PolicyLatestRescheduleInMinutes = exports.PolicyEarliestBookingInMinutes = exports.PolicyLatestBookingInMinutes = exports.PolicyLatestCancellationInMinutes = exports.Actions = exports.Raw = exports.StaffMemberRepeater = exports.StaffMembersList = exports.LocationRepeater = exports.LocationsList = exports.Category = exports.Type = exports.DurationRange = exports.DurationInMinutes = exports.Tagline = exports.Price = exports.Description = exports.Name = exports.Root = exports.TestIds = void 0;
40
40
  const jsx_runtime_1 = require("react/jsx-runtime");
41
41
  /**
42
42
  * Service - High-level component for displaying service information
@@ -63,6 +63,7 @@ exports.TestIds = {
63
63
  servicePrice: 'service-price',
64
64
  serviceTagline: 'service-tagline',
65
65
  serviceDurationInMinutes: 'service-duration-in-minutes',
66
+ serviceDurationRange: 'service-duration-range',
66
67
  serviceType: 'service-type',
67
68
  serviceCategory: 'service-category',
68
69
  serviceLocations: 'service-locations',
@@ -341,6 +342,85 @@ exports.DurationInMinutes = react_1.default.forwardRef((props, ref) => {
341
342
  } }));
342
343
  });
343
344
  exports.DurationInMinutes.displayName = 'Service.DurationInMinutes';
345
+ /**
346
+ * Provides the service's supported session duration range as raw SDK data.
347
+ * Renders nothing when the service has fewer than two distinct supported
348
+ * durations — use {@link DurationInMinutes} for that case.
349
+ *
350
+ * The component is intentionally UI-agnostic: it does not pick formatting,
351
+ * units, or labels for you. The default render outputs only the raw
352
+ * `min - max` numbers (no unit text). Consumers wanting unit-aware UI use
353
+ * `asChild` with a custom render and narrow on the SDK `range` payload
354
+ * (`range.hourOptions` / `range.dayOptions` / `range.unitType`, or any
355
+ * other unit configuration the SDK adds in the future).
356
+ *
357
+ * @component
358
+ * @example
359
+ * ```tsx
360
+ * // Default usage - displays raw min/max, e.g. "120 - 540" or "2 - 5"
361
+ * <Service.DurationRange className="text-base text-secondary-foreground" />
362
+ * ```
363
+ *
364
+ * @example
365
+ * ```tsx
366
+ * // asChild with primitive element
367
+ * <Service.DurationRange asChild>
368
+ * <span className="font-semibold" />
369
+ * </Service.DurationRange>
370
+ * ```
371
+ *
372
+ * @example
373
+ * ```tsx
374
+ * // asChild with custom component - narrow on the SDK range payload to
375
+ * // decide unit-specific formatting.
376
+ * <Service.DurationRange asChild>
377
+ * {React.forwardRef(({ range, ...props }, ref) => {
378
+ * if (range.hourOptions) {
379
+ * const { minDurationInMinutes: min, maxDurationInMinutes: max } =
380
+ * range.hourOptions;
381
+ * return (
382
+ * <span ref={ref} {...props}>
383
+ * {min}-{max} min
384
+ * </span>
385
+ * );
386
+ * }
387
+ * if (range.dayOptions) {
388
+ * const { minDurationInDays: min, maxDurationInDays: max } =
389
+ * range.dayOptions;
390
+ * return (
391
+ * <span ref={ref} {...props}>
392
+ * {min}-{max} days
393
+ * </span>
394
+ * );
395
+ * }
396
+ * return <span ref={ref} {...props} />;
397
+ * })}
398
+ * </Service.DurationRange>
399
+ * ```
400
+ */
401
+ exports.DurationRange = react_1.default.forwardRef((props, ref) => {
402
+ const { asChild, children, ...rest } = props;
403
+ return ((0, jsx_runtime_1.jsx)(CoreService.Info, { children: ({ durationRange }) => {
404
+ if (!durationRange)
405
+ return null;
406
+ // When `unitType` is missing or unrecognised, no default content is
407
+ // rendered — consumers can still read the raw `range` via asChild.
408
+ const { unitType, hourOptions, dayOptions } = durationRange;
409
+ let min;
410
+ let max;
411
+ if (unitType === auto_sdk_bookings_services_1.UnitType.HOUR) {
412
+ min = hourOptions?.minDurationInMinutes;
413
+ max = hourOptions?.maxDurationInMinutes;
414
+ }
415
+ else if (unitType === auto_sdk_bookings_services_1.UnitType.DAY) {
416
+ min = dayOptions?.minDurationInDays;
417
+ max = dayOptions?.maxDurationInDays;
418
+ }
419
+ const hasRange = min != null && max != null;
420
+ return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, ...rest, "data-testid": exports.TestIds.serviceDurationRange, customElement: children, customElementProps: { range: durationRange }, children: hasRange ? (0, jsx_runtime_1.jsx)("span", { children: `${min} - ${max}` }) : null }));
421
+ } }));
422
+ });
423
+ exports.DurationRange.displayName = 'Service.DurationRange';
344
424
  /**
345
425
  * Displays the service type (APPOINTMENT, CLASS, COURSE, etc.) with customizable rendering.
346
426
  *
@@ -1,24 +1,2 @@
1
- /**
2
- * Book Action - Orchestrates the booking flow
3
- *
4
- * 1. Validates booking data with canBook()
5
- * 2. Creates a booking via createBooking() from API layer
6
- * 3. Creates a checkout via createCheckout() from API layer
7
- * 4. Determines if checkout is required or can be skipped
8
- * 5. Returns appropriate result for navigation
9
- */
10
1
  import { type BookActionParams, type BookResult } from './types.js';
11
- /**
12
- * Executes the complete booking flow:
13
- * 1. Validates that all required data is present
14
- * 2. Creates a booking with the selected service, time slot, and form data
15
- * 3. Creates a checkout session for payment (includes contact details from booking)
16
- * 4. Determines if checkout page is required or can be skipped
17
- * 5. If checkout can be skipped (free/offline), creates order directly
18
- * 6. Returns appropriate result for navigation
19
- *
20
- * @param params - The booking action parameters
21
- * @returns BookResult with either checkoutId or orderId
22
- * @throws Error if validation fails, or booking/checkout/order creation fails
23
- */
24
2
  export declare function executeBookAction(params: BookActionParams): Promise<BookResult>;