@wix/headless-bookings 1.0.4 → 1.0.6

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 (67) hide show
  1. package/cjs/dist/__mocks__/booking/booking-client-service.js +4 -1
  2. package/cjs/dist/api/create-booking/index.d.ts +4 -4
  3. package/cjs/dist/api/create-bulk-booking/index.d.ts +54 -0
  4. package/cjs/dist/api/create-bulk-booking/index.js +54 -0
  5. package/cjs/dist/api/create-multi-service-booking/index.d.ts +53 -0
  6. package/cjs/dist/api/create-multi-service-booking/index.js +47 -0
  7. package/cjs/dist/api/index.d.ts +4 -1
  8. package/cjs/dist/api/index.js +32 -13
  9. package/cjs/dist/react/core/booking/Booking.d.ts +6 -1
  10. package/cjs/dist/react/core/booking/Booking.js +2 -0
  11. package/cjs/dist/services/booking/book-action/bookAction.js +39 -27
  12. package/cjs/dist/services/booking/book-action/buildBookingRequest.d.ts +1 -1
  13. package/cjs/dist/services/booking/book-action/buildBookingRequest.js +4 -2
  14. package/cjs/dist/services/booking/book-action/buildCartRequest.d.ts +20 -2
  15. package/cjs/dist/services/booking/book-action/buildCartRequest.js +24 -13
  16. package/cjs/dist/services/booking/book-action/buildDayRangeBookingRequest.d.ts +37 -0
  17. package/cjs/dist/services/booking/book-action/buildDayRangeBookingRequest.js +70 -0
  18. package/cjs/dist/services/booking/book-action/canBook.d.ts +2 -1
  19. package/cjs/dist/services/booking/book-action/canBook.js +4 -2
  20. package/cjs/dist/services/booking/book-action/createBookingsForCart.d.ts +22 -0
  21. package/cjs/dist/services/booking/book-action/createBookingsForCart.js +69 -0
  22. package/cjs/dist/services/booking/book-action/dayRange.d.ts +34 -0
  23. package/cjs/dist/services/booking/book-action/dayRange.js +43 -0
  24. package/cjs/dist/services/booking/book-action/index.d.ts +9 -6
  25. package/cjs/dist/services/booking/book-action/index.js +23 -13
  26. package/cjs/dist/services/booking/book-action/types.d.ts +15 -0
  27. package/cjs/dist/services/booking/booking.d.ts +31 -2
  28. package/cjs/dist/services/booking/booking.js +8 -0
  29. package/cjs/dist/services/index.d.ts +1 -1
  30. package/cjs/dist/services/index.js +6 -1
  31. package/cjs/dist/services/payment/payment.d.ts +4 -0
  32. package/cjs/dist/services/payment/payment.def.d.ts +6 -0
  33. package/cjs/dist/services/payment/payment.js +39 -17
  34. package/dist/__mocks__/booking/booking-client-service.js +4 -1
  35. package/dist/api/create-booking/index.d.ts +4 -4
  36. package/dist/api/create-bulk-booking/index.d.ts +54 -0
  37. package/dist/api/create-bulk-booking/index.js +51 -0
  38. package/dist/api/create-multi-service-booking/index.d.ts +53 -0
  39. package/dist/api/create-multi-service-booking/index.js +44 -0
  40. package/dist/api/index.d.ts +4 -1
  41. package/dist/api/index.js +3 -0
  42. package/dist/react/core/booking/Booking.d.ts +6 -1
  43. package/dist/react/core/booking/Booking.js +2 -0
  44. package/dist/services/booking/book-action/bookAction.js +34 -22
  45. package/dist/services/booking/book-action/buildBookingRequest.d.ts +1 -1
  46. package/dist/services/booking/book-action/buildBookingRequest.js +4 -2
  47. package/dist/services/booking/book-action/buildCartRequest.d.ts +20 -2
  48. package/dist/services/booking/book-action/buildCartRequest.js +23 -13
  49. package/dist/services/booking/book-action/buildDayRangeBookingRequest.d.ts +37 -0
  50. package/dist/services/booking/book-action/buildDayRangeBookingRequest.js +67 -0
  51. package/dist/services/booking/book-action/canBook.d.ts +2 -1
  52. package/dist/services/booking/book-action/canBook.js +4 -2
  53. package/dist/services/booking/book-action/createBookingsForCart.d.ts +22 -0
  54. package/dist/services/booking/book-action/createBookingsForCart.js +66 -0
  55. package/dist/services/booking/book-action/dayRange.d.ts +34 -0
  56. package/dist/services/booking/book-action/dayRange.js +39 -0
  57. package/dist/services/booking/book-action/index.d.ts +9 -6
  58. package/dist/services/booking/book-action/index.js +9 -6
  59. package/dist/services/booking/book-action/types.d.ts +15 -0
  60. package/dist/services/booking/booking.d.ts +31 -2
  61. package/dist/services/booking/booking.js +8 -0
  62. package/dist/services/index.d.ts +1 -1
  63. package/dist/services/index.js +1 -1
  64. package/dist/services/payment/payment.d.ts +4 -0
  65. package/dist/services/payment/payment.def.d.ts +6 -0
  66. package/dist/services/payment/payment.js +39 -17
  67. package/package.json +2 -2
@@ -29,16 +29,18 @@ function createMockSignalsService() {
29
29
  };
30
30
  }
31
31
  function createMockBookingService(config = {}) {
32
- const { serviceSelections = [], location = null, timezone = 'UTC', formSubmission = null, } = config;
32
+ const { serviceSelections = [], location = null, timezone = 'UTC', formSubmission = null, selectedPaymentOption, } = config;
33
33
  const serviceSelectionsSignal = mockSignal(serviceSelections);
34
34
  const locationSignal = mockSignal(location);
35
35
  const timezoneSignal = mockSignal(timezone);
36
36
  const formSubmissionSignal = mockSignal(formSubmission);
37
+ const selectedPaymentOptionSignal = mockSignal(selectedPaymentOption);
37
38
  return {
38
39
  serviceSelections: serviceSelectionsSignal,
39
40
  location: locationSignal,
40
41
  timezone: timezoneSignal,
41
42
  formSubmission: formSubmissionSignal,
43
+ selectedPaymentOption: selectedPaymentOptionSignal,
42
44
  actions: {
43
45
  updateItem: vitest_1.vi.fn(),
44
46
  setItem: vitest_1.vi.fn(),
@@ -53,6 +55,7 @@ function createMockBookingService(config = {}) {
53
55
  setTimezone: vitest_1.vi.fn(),
54
56
  setFormSubmission: vitest_1.vi.fn(),
55
57
  clearFormSubmission: vitest_1.vi.fn(),
58
+ setSelectedPaymentOption: vitest_1.vi.fn(),
56
59
  clearAll: vitest_1.vi.fn(),
57
60
  book: vitest_1.vi.fn(),
58
61
  },
@@ -5,15 +5,16 @@
5
5
  import { type Booking, type CreateBookingResponse, type ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
6
6
  import type { FormValues } from '@wix/forms/components';
7
7
  /**
8
- * Options for creating a booking
8
+ * Options for creating a booking. `null` is accepted on optional fields so
9
+ * callers can forward the SDK's `T | null` shape without coercion.
9
10
  */
10
11
  export interface CreateBookingOptions {
11
12
  /** Notification settings for participants */
12
13
  participantNotification?: ParticipantNotification;
13
14
  /** Whether to send SMS reminder */
14
- sendSmsReminder?: boolean;
15
+ sendSmsReminder?: boolean | null;
15
16
  /** Form submission data */
16
- formSubmission?: FormValues;
17
+ formSubmission?: FormValues | null;
17
18
  }
18
19
  /**
19
20
  * Creates a booking with the specified booking data and options
@@ -39,4 +40,3 @@ export interface CreateBookingOptions {
39
40
  * ```
40
41
  */
41
42
  export declare function createBooking(booking: Booking, options?: CreateBookingOptions): Promise<CreateBookingResponse>;
42
- export type { Booking, CreateBookingRequest, CreateBookingResponse, ParticipantNotification, ContactDetails, } from '@wix/auto_sdk_bookings_bookings';
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Bulk Create Booking API
3
+ * Wrapper for the Wix Bookings bulkCreateBooking SDK function.
4
+ *
5
+ * Used for the 1-day case of the DAY-range expansion: a single APPOINTMENT
6
+ * service whose duration is configured as a DAY range, with exactly one
7
+ * per-day availability slot picked. The 2-8 day case is routed to
8
+ * createMultiServiceBooking.
9
+ */
10
+ import { type CreateBookingInfo, type BulkCreateBookingResponse, type ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
11
+ /**
12
+ * Options for creating bookings in bulk.
13
+ *
14
+ * `formSubmission` is intentionally absent: the SDK's
15
+ * `BulkCreateBookingOptions` does not accept it. Customer details flow
16
+ * through the cart layer instead. We always set `returnFullEntity: true` so
17
+ * the response includes per-booking entities (with `contactDetails`) for
18
+ * cart wiring.
19
+ */
20
+ export interface BulkCreateBookingOptions {
21
+ /** Notification settings for participants. Applied to every entry. */
22
+ participantNotification?: ParticipantNotification;
23
+ /** Whether to send SMS reminder. Applied to every entry. */
24
+ sendSmsReminder?: boolean;
25
+ }
26
+ /**
27
+ * Creates 1-8 bookings in a single bulk call.
28
+ *
29
+ * Per the SDK contract, `createBookingsInfo` accepts 1-8 bookings. When the
30
+ * DAY-range routing picks exactly one per-day slot, this wrapper is invoked
31
+ * with a single-element array. Validation of constraints is delegated to the
32
+ * SDK; this wrapper only forwards the request and pins
33
+ * `returnFullEntity: true` so the caller can read
34
+ * `results[].item.contactDetails` for downstream cart construction.
35
+ *
36
+ * @param createBookingsInfo - 1-8 single-service booking specifications
37
+ * @param options - Optional notification / SMS settings (applied to every entry)
38
+ * @returns Promise resolving to the bulk-create response
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const response = await bulkCreateBooking(
43
+ * [{ booking: bookingDay1 }],
44
+ * {
45
+ * participantNotification: { notifyParticipants: true },
46
+ * sendSmsReminder: true,
47
+ * }
48
+ * );
49
+ * const ids = response.results
50
+ * ?.map((r) => r.item?._id)
51
+ * .filter(Boolean);
52
+ * ```
53
+ */
54
+ export declare function bulkCreateBooking(createBookingsInfo: CreateBookingInfo[], options?: BulkCreateBookingOptions): Promise<BulkCreateBookingResponse>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /**
3
+ * Bulk Create Booking API
4
+ * Wrapper for the Wix Bookings bulkCreateBooking SDK function.
5
+ *
6
+ * Used for the 1-day case of the DAY-range expansion: a single APPOINTMENT
7
+ * service whose duration is configured as a DAY range, with exactly one
8
+ * per-day availability slot picked. The 2-8 day case is routed to
9
+ * createMultiServiceBooking.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.bulkCreateBooking = bulkCreateBooking;
13
+ const auto_sdk_bookings_bookings_1 = require("@wix/auto_sdk_bookings_bookings");
14
+ /**
15
+ * Creates 1-8 bookings in a single bulk call.
16
+ *
17
+ * Per the SDK contract, `createBookingsInfo` accepts 1-8 bookings. When the
18
+ * DAY-range routing picks exactly one per-day slot, this wrapper is invoked
19
+ * with a single-element array. Validation of constraints is delegated to the
20
+ * SDK; this wrapper only forwards the request and pins
21
+ * `returnFullEntity: true` so the caller can read
22
+ * `results[].item.contactDetails` for downstream cart construction.
23
+ *
24
+ * @param createBookingsInfo - 1-8 single-service booking specifications
25
+ * @param options - Optional notification / SMS settings (applied to every entry)
26
+ * @returns Promise resolving to the bulk-create response
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const response = await bulkCreateBooking(
31
+ * [{ booking: bookingDay1 }],
32
+ * {
33
+ * participantNotification: { notifyParticipants: true },
34
+ * sendSmsReminder: true,
35
+ * }
36
+ * );
37
+ * const ids = response.results
38
+ * ?.map((r) => r.item?._id)
39
+ * .filter(Boolean);
40
+ * ```
41
+ */
42
+ function bulkCreateBooking(createBookingsInfo, options) {
43
+ // Apply the shared participantNotification / sendSmsReminder onto each
44
+ // CreateBookingInfo entry. The SDK's per-call options object only carries
45
+ // `returnFullEntity`, so notification settings live on each entry.
46
+ const enriched = createBookingsInfo.map((info) => ({
47
+ ...info,
48
+ participantNotification: info.participantNotification ?? options?.participantNotification,
49
+ sendSmsReminder: info.sendSmsReminder ?? options?.sendSmsReminder,
50
+ }));
51
+ return (0, auto_sdk_bookings_bookings_1.bulkCreateBooking)(enriched, {
52
+ returnFullEntity: true,
53
+ });
54
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Create Multi-Service Booking API
3
+ * Wrapper for the Wix Bookings createMultiServiceBooking SDK function.
4
+ *
5
+ * Used for the 2-8 day case of the DAY-range expansion: a single
6
+ * APPOINTMENT service whose duration is configured as a DAY range, with
7
+ * 2-8 per-day availability slots picked. One Booking entry is sent per
8
+ * picked slot.
9
+ */
10
+ import { type Booking, type CreateMultiServiceBookingResponse, type ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
11
+ /**
12
+ * Options for creating a multi-service booking.
13
+ *
14
+ * `formSubmission` is intentionally absent: the SDK's
15
+ * `CreateMultiServiceBookingOptions` does not accept it. Customer details
16
+ * flow through the cart layer instead. We always set `returnFullEntity: true`
17
+ * so the response includes per-booking entities (with `contactDetails`) for
18
+ * cart wiring.
19
+ */
20
+ export interface CreateMultiServiceBookingOptions {
21
+ /** Notification settings for participants */
22
+ participantNotification?: ParticipantNotification;
23
+ /** Whether to send SMS reminder */
24
+ sendSmsReminder?: boolean;
25
+ }
26
+ /**
27
+ * Creates a multi-service booking from 2-8 single-service booking specs.
28
+ *
29
+ * Per the SDK contract, the bookings array must contain 2-8 APPOINTMENT
30
+ * bookings at the same location with sequential, gapless scheduling.
31
+ * Validation of those constraints is delegated to the SDK; this wrapper only
32
+ * forwards the request and pins `returnFullEntity: true` so the caller can
33
+ * read `bookings[].booking.contactDetails` for downstream cart construction.
34
+ *
35
+ * @param bookings - 2 to 8 single-service booking specifications
36
+ * @param options - Optional notification / SMS settings
37
+ * @returns Promise resolving to the created multi-service booking response
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const response = await createMultiServiceBooking(
42
+ * [bookingDay1, bookingDay2, bookingDay3],
43
+ * {
44
+ * participantNotification: { notifyParticipants: true },
45
+ * sendSmsReminder: true,
46
+ * }
47
+ * );
48
+ * const ids = response.multiServiceBooking?.bookings
49
+ * ?.map((b) => b.bookingId)
50
+ * .filter(Boolean);
51
+ * ```
52
+ */
53
+ export declare function createMultiServiceBooking(bookings: Booking[], options?: CreateMultiServiceBookingOptions): Promise<CreateMultiServiceBookingResponse>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /**
3
+ * Create Multi-Service Booking API
4
+ * Wrapper for the Wix Bookings createMultiServiceBooking SDK function.
5
+ *
6
+ * Used for the 2-8 day case of the DAY-range expansion: a single
7
+ * APPOINTMENT service whose duration is configured as a DAY range, with
8
+ * 2-8 per-day availability slots picked. One Booking entry is sent per
9
+ * picked slot.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.createMultiServiceBooking = createMultiServiceBooking;
13
+ const auto_sdk_bookings_bookings_1 = require("@wix/auto_sdk_bookings_bookings");
14
+ /**
15
+ * Creates a multi-service booking from 2-8 single-service booking specs.
16
+ *
17
+ * Per the SDK contract, the bookings array must contain 2-8 APPOINTMENT
18
+ * bookings at the same location with sequential, gapless scheduling.
19
+ * Validation of those constraints is delegated to the SDK; this wrapper only
20
+ * forwards the request and pins `returnFullEntity: true` so the caller can
21
+ * read `bookings[].booking.contactDetails` for downstream cart construction.
22
+ *
23
+ * @param bookings - 2 to 8 single-service booking specifications
24
+ * @param options - Optional notification / SMS settings
25
+ * @returns Promise resolving to the created multi-service booking response
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const response = await createMultiServiceBooking(
30
+ * [bookingDay1, bookingDay2, bookingDay3],
31
+ * {
32
+ * participantNotification: { notifyParticipants: true },
33
+ * sendSmsReminder: true,
34
+ * }
35
+ * );
36
+ * const ids = response.multiServiceBooking?.bookings
37
+ * ?.map((b) => b.bookingId)
38
+ * .filter(Boolean);
39
+ * ```
40
+ */
41
+ function createMultiServiceBooking(bookings, options) {
42
+ return (0, auto_sdk_bookings_bookings_1.createMultiServiceBooking)(bookings, {
43
+ participantNotification: options?.participantNotification,
44
+ sendSmsReminder: options?.sendSmsReminder,
45
+ returnFullEntity: true,
46
+ });
47
+ }
@@ -6,7 +6,10 @@
6
6
  */
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
- export { createBooking, type CreateBookingOptions, type Booking, type CreateBookingRequest, type CreateBookingResponse, type ParticipantNotification, type ContactDetails, } from './create-booking/index.js';
9
+ export * from '@wix/auto_sdk_bookings_bookings';
10
+ export { createBooking, type CreateBookingOptions, } from './create-booking/index.js';
11
+ export { bulkCreateBooking, type BulkCreateBookingOptions, } from './create-bulk-booking/index.js';
12
+ export { createMultiServiceBooking, type CreateMultiServiceBookingOptions, } from './create-multi-service-booking/index.js';
10
13
  export { createCart, ChannelType, type CreateCartOptions, type Cart, } from './create-cart/index.js';
11
14
  export { calculateCart, type CalculateCartResponse, type CartSummary, } from './calculate-cart/index.js';
12
15
  export { placeOrder, type PlaceOrderOptions, type PlaceOrderResponse, } from './place-order/index.js';
@@ -5,8 +5,22 @@
5
5
  *
6
6
  * @module API
7
7
  */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
8
22
  Object.defineProperty(exports, "__esModule", { value: true });
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;
23
+ exports.queryCategories = exports.getLocationById = exports.queryLocations = exports.placeOrder = exports.calculateCart = exports.ChannelType = exports.createCart = exports.createMultiServiceBooking = exports.bulkCreateBooking = exports.createBooking = exports.fetchAvailability = exports.SYNTHETIC_CUSTOMER_ID = exports.SYNTHETIC_CUSTOM_ID = exports.convertPlatformFilterToApiFilter = exports.queryServices = exports.getServiceBySlug = exports.getServiceById = void 0;
10
24
  var index_js_1 = require("./query-services/index.js");
11
25
  Object.defineProperty(exports, "getServiceById", { enumerable: true, get: function () { return index_js_1.getServiceById; } });
12
26
  Object.defineProperty(exports, "getServiceBySlug", { enumerable: true, get: function () { return index_js_1.getServiceBySlug; } });
@@ -16,17 +30,22 @@ Object.defineProperty(exports, "SYNTHETIC_CUSTOM_ID", { enumerable: true, get: f
16
30
  Object.defineProperty(exports, "SYNTHETIC_CUSTOMER_ID", { enumerable: true, get: function () { return index_js_1.SYNTHETIC_CUSTOMER_ID; } });
17
31
  var index_js_2 = require("./fetch-availability/index.js");
18
32
  Object.defineProperty(exports, "fetchAvailability", { enumerable: true, get: function () { return index_js_2.fetchAvailability; } });
33
+ __exportStar(require("@wix/auto_sdk_bookings_bookings"), exports);
19
34
  var index_js_3 = require("./create-booking/index.js");
20
35
  Object.defineProperty(exports, "createBooking", { enumerable: true, get: function () { return index_js_3.createBooking; } });
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
- Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return index_js_4.ChannelType; } });
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; } });
36
+ var index_js_4 = require("./create-bulk-booking/index.js");
37
+ Object.defineProperty(exports, "bulkCreateBooking", { enumerable: true, get: function () { return index_js_4.bulkCreateBooking; } });
38
+ var index_js_5 = require("./create-multi-service-booking/index.js");
39
+ Object.defineProperty(exports, "createMultiServiceBooking", { enumerable: true, get: function () { return index_js_5.createMultiServiceBooking; } });
40
+ var index_js_6 = require("./create-cart/index.js");
41
+ Object.defineProperty(exports, "createCart", { enumerable: true, get: function () { return index_js_6.createCart; } });
42
+ Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return index_js_6.ChannelType; } });
43
+ var index_js_7 = require("./calculate-cart/index.js");
44
+ Object.defineProperty(exports, "calculateCart", { enumerable: true, get: function () { return index_js_7.calculateCart; } });
45
+ var index_js_8 = require("./place-order/index.js");
46
+ Object.defineProperty(exports, "placeOrder", { enumerable: true, get: function () { return index_js_8.placeOrder; } });
47
+ var index_js_9 = require("./query-locations/index.js");
48
+ Object.defineProperty(exports, "queryLocations", { enumerable: true, get: function () { return index_js_9.queryLocations; } });
49
+ Object.defineProperty(exports, "getLocationById", { enumerable: true, get: function () { return index_js_9.getLocationById; } });
50
+ var index_js_10 = require("./query-categories/index.js");
51
+ Object.defineProperty(exports, "queryCategories", { enumerable: true, get: function () { return index_js_10.queryCategories; } });
@@ -3,7 +3,7 @@
3
3
  * Provides low-level access to BookingService via render props and service setup
4
4
  */
5
5
  import React from 'react';
6
- import { type BookingServiceConfig, type ServiceSelection, type BookingServiceActions } from '../../../services/booking/booking.js';
6
+ import { type BookingServiceConfig, type ServiceSelection, type BookingServiceActions, type SelectedPaymentOption } 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
9
  import { type Service, type V2Location as ServiceLocationType } from '@wix/auto_sdk_bookings_services';
@@ -40,6 +40,11 @@ export interface BookingData {
40
40
  location: ServiceLocationType | null;
41
41
  timezone: string | undefined;
42
42
  formSubmission: FormValues | null;
43
+ /**
44
+ * Consumer-selected payment option. `undefined` means the service-config
45
+ * heuristic applies. Set via `actions.setSelectedPaymentOption`.
46
+ */
47
+ selectedPaymentOption: SelectedPaymentOption | undefined;
43
48
  actions: BookingServiceActions;
44
49
  }
45
50
  /**
@@ -117,6 +117,7 @@ function Data(props) {
117
117
  const bookingLocation = bookingService.location.get();
118
118
  const timezone = bookingService.timezone.get();
119
119
  const formSubmission = bookingService.formSubmission.get();
120
+ const selectedPaymentOption = bookingService.selectedPaymentOption.get();
120
121
  const { actions } = bookingService;
121
122
  const location = resolveLocation(bookingLocation, serviceSelections);
122
123
  return children({
@@ -124,6 +125,7 @@ function Data(props) {
124
125
  location,
125
126
  timezone,
126
127
  formSubmission,
128
+ selectedPaymentOption,
127
129
  actions,
128
130
  });
129
131
  }
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeBookAction = executeBookAction;
4
- const index_js_1 = require("../../../api/create-booking/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");
8
- const buildBookingRequest_js_1 = require("./buildBookingRequest.js");
4
+ const index_js_1 = require("../../../api/create-cart/index.js");
5
+ const index_js_2 = require("../../../api/calculate-cart/index.js");
6
+ const index_js_3 = require("../../../api/place-order/index.js");
9
7
  const buildCartRequest_js_1 = require("./buildCartRequest.js");
10
8
  const canBook_js_1 = require("./canBook.js");
9
+ const createBookingsForCart_js_1 = require("./createBookingsForCart.js");
11
10
  const isCheckoutRequired_js_1 = require("./isCheckoutRequired.js");
11
+ const dayRange_js_1 = require("./dayRange.js");
12
12
  const types_js_1 = require("./types.js");
13
13
  async function executeBookAction(params) {
14
14
  if (!(0, canBook_js_1.canBook)({
@@ -17,46 +17,58 @@ async function executeBookAction(params) {
17
17
  })) {
18
18
  throw new Error('Cannot book: missing required data');
19
19
  }
20
- // Step 1: Create booking
21
- const createBookingRequest = (0, buildBookingRequest_js_1.buildBookingRequest)(params);
22
- const bookingResponse = await (0, index_js_1.createBooking)(createBookingRequest.booking, {
23
- participantNotification: createBookingRequest.participantNotification,
24
- sendSmsReminder: createBookingRequest.sendSmsReminder ?? undefined,
25
- formSubmission: createBookingRequest.formSubmission ?? undefined,
26
- });
27
- const bookingId = bookingResponse.booking?._id;
28
- const contactDetails = bookingResponse.booking?.contactDetails;
29
- if (!bookingId) {
20
+ // Step 1: Create booking(s). The helper picks single vs bulk vs
21
+ // multi-service (DAY-range routing) and returns a uniform
22
+ // { bookingIds, contactDetails } shape.
23
+ const { bookingIds, contactDetails } = await (0, createBookingsForCart_js_1.createBookingsForCart)(params);
24
+ if (bookingIds.length === 0) {
30
25
  throw new Error('Failed to create booking');
31
26
  }
32
- // Step 2: Create cart
27
+ // Step 2: Create cart. `firstSelection` is guaranteed non-empty because
28
+ // `canBook` already enforced `serviceSelections.length > 0` above.
33
29
  const firstSelection = params.serviceSelections[0];
34
30
  if (!firstSelection) {
35
31
  throw new Error('No service selection found');
36
32
  }
37
- const businessLocationId = firstSelection.timeSlot?.location?._id ?? undefined;
38
- const cartRequest = (0, buildCartRequest_js_1.buildCartRequest)({
39
- bookingId,
40
- contactDetails,
41
- businessLocationId,
42
- appId: params.appId,
43
- });
44
- const cart = await (0, index_js_2.createCart)(cartRequest);
33
+ const isDayRange = (0, dayRange_js_1.isDayRangeService)(firstSelection.service);
34
+ const businessLocationId = isDayRange
35
+ ? // TODO: derive from the selected resource (staff member)'s location
36
+ // once the resource-location work lands. Until then, the DAY-range
37
+ // slot list doesn't reliably carry per-slot location, so we read
38
+ // it from the service's first configured location.
39
+ firstSelection.service.locations?.[0]?._id
40
+ : firstSelection.timeSlot?.location?._id;
41
+ const cartRequest = isDayRange
42
+ ? (0, buildCartRequest_js_1.buildDayRangeCartRequest)({
43
+ bookingIds,
44
+ contactDetails,
45
+ businessLocationId,
46
+ appId: params.appId,
47
+ })
48
+ : (0, buildCartRequest_js_1.buildCartRequest)({
49
+ bookingId: bookingIds[0],
50
+ contactDetails,
51
+ businessLocationId,
52
+ appId: params.appId,
53
+ });
54
+ const cart = await (0, index_js_1.createCart)(cartRequest);
45
55
  if (!cart._id) {
46
56
  throw new Error('Failed to create cart');
47
57
  }
48
58
  // 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);
59
+ const { cart: calculatedCart, summary } = await (0, index_js_2.calculateCart)(cart._id);
50
60
  if (!calculatedCart || !summary) {
51
61
  throw new Error('Failed to calculate cart');
52
62
  }
53
- // Step 4: Determine if checkout is required or can be skipped
63
+ // Step 4: Determine if checkout is required or can be skipped. For
64
+ // DAY-range expansion all N bookings are the same service, so reading the
65
+ // first selection's service is still correct.
54
66
  const service = firstSelection.service;
55
67
  if ((0, isCheckoutRequired_js_1.isCheckoutRequired)(calculatedCart, summary, service)) {
56
68
  return { type: types_js_1.BookResultType.CheckoutRequired, cartId: cart._id };
57
69
  }
58
70
  // Step 5: Skip checkout — place order directly
59
- const orderResponse = await (0, index_js_4.placeOrder)(cart._id);
71
+ const orderResponse = await (0, index_js_3.placeOrder)(cart._id);
60
72
  const orderId = orderResponse.orderId;
61
73
  if (!orderId) {
62
74
  throw new Error('Failed to place order');
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Builds the createBooking request from BookActionParams
3
3
  */
4
- import type { CreateBookingRequest } from '../../../api/create-booking/index.js';
4
+ import { type CreateBookingRequest } from '@wix/auto_sdk_bookings_bookings';
5
5
  import type { BookActionParams } from './types.js';
6
6
  /**
7
7
  * Builds a CreateBookingRequest from the booking action parameters
@@ -58,8 +58,10 @@ function buildBookingRequest(params) {
58
58
  const slotLocation = item.timeSlot.location ?? location;
59
59
  return {
60
60
  booking: {
61
- // Payment option derived from service payment settings
62
- selectedPaymentOption: deriveSelectedPaymentOption(item.service),
61
+ // Payment option: consumer override (if set) wins over the
62
+ // service-config heuristic.
63
+ selectedPaymentOption: params.selectedPaymentOption ??
64
+ deriveSelectedPaymentOption(item.service),
63
65
  // Participants
64
66
  totalParticipants: item.totalParticipants || 1,
65
67
  // Booked entity slot
@@ -1,10 +1,28 @@
1
1
  import { type CreateCartOptions } from '../../../api/create-cart/index.js';
2
- import type { ContactDetails } from '../../../api/create-booking/index.js';
2
+ import type { ContactDetails } from '@wix/auto_sdk_bookings_bookings';
3
3
  export interface BuildCartParams {
4
4
  bookingId: string;
5
5
  contactDetails?: ContactDetails;
6
- businessLocationId?: string;
6
+ /** `null` accepted so callers can forward SDK fields typed `string | null`. */
7
+ businessLocationId?: string | null;
7
8
  /** Optional app ID override for the catalog reference. Defaults to BOOKING_APP_ID. */
8
9
  appId?: string;
9
10
  }
10
11
  export declare function buildCartRequest(params: BuildCartParams): CreateCartOptions;
12
+ /**
13
+ * DAY-range variant of `buildCartRequest`. Takes the N booking IDs returned
14
+ * by `bulkCreateBooking` (1 slot) or `createMultiServiceBooking` (2-8 slots)
15
+ * and emits one catalog item per ID. Per SDK guidance, never use
16
+ * `multiServiceBooking._id` here; always feed the per-day single-service
17
+ * booking IDs into the cart.
18
+ */
19
+ export interface BuildDayRangeCartParams {
20
+ /** One catalog item per booking id. Bulk / multi-service responses produce N>=1 ids. */
21
+ bookingIds: string[];
22
+ contactDetails?: ContactDetails;
23
+ /** `null` accepted so callers can forward SDK fields typed `string | null`. */
24
+ businessLocationId?: string | null;
25
+ /** Optional app ID override for the catalog reference. Defaults to BOOKING_APP_ID. */
26
+ appId?: string;
27
+ }
28
+ export declare function buildDayRangeCartRequest(params: BuildDayRangeCartParams): CreateCartOptions;
@@ -1,10 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildCartRequest = buildCartRequest;
4
+ exports.buildDayRangeCartRequest = buildDayRangeCartRequest;
4
5
  const index_js_1 = require("../../../api/create-cart/index.js");
5
6
  const constants_js_1 = require("../../constants.js");
6
7
  function buildCartRequest(params) {
7
- const { bookingId, contactDetails, businessLocationId, appId } = params;
8
+ return {
9
+ catalogItems: [buildCatalogItem(params.bookingId, params.appId)],
10
+ cart: buildCartShape(params),
11
+ };
12
+ }
13
+ function buildDayRangeCartRequest(params) {
14
+ return {
15
+ catalogItems: params.bookingIds.map((id) => buildCatalogItem(id, params.appId)),
16
+ cart: buildCartShape(params),
17
+ };
18
+ }
19
+ function buildCatalogItem(bookingId, appId) {
20
+ return {
21
+ quantity: 1,
22
+ catalogReference: {
23
+ catalogItemId: bookingId,
24
+ appId: appId ?? constants_js_1.BOOKING_APP_ID,
25
+ },
26
+ };
27
+ }
28
+ function buildCartShape(params) {
29
+ const { contactDetails, businessLocationId } = params;
8
30
  const cart = {
9
31
  source: { channelType: index_js_1.ChannelType.WEB },
10
32
  };
@@ -22,16 +44,5 @@ function buildCartRequest(params) {
22
44
  };
23
45
  }
24
46
  }
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
- };
47
+ return cart;
37
48
  }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Builds the request payload(s) for a single APPOINTMENT service whose
3
+ * duration is configured as a DAY range.
4
+ *
5
+ * The slot list comes from availability — the user picks a start + end date
6
+ * and the picker emits one slot per day in `rangeTimeSlots`. The client just
7
+ * packages them as one Booking each. Routing is decided by `bookings.length`
8
+ * in `createBookingsForCart`:
9
+ * - length 1 -> `bulkCreateBooking`
10
+ * - length 2-8 -> `createMultiServiceBooking`
11
+ *
12
+ * The 8-day cap is enforced server-side; the builder does not gate on it.
13
+ */
14
+ import type { Booking, ParticipantNotification } from '@wix/auto_sdk_bookings_bookings';
15
+ import type { BookActionParams } from './types.js';
16
+ export interface BuildDayRangeBookingRequest {
17
+ /**
18
+ * One Booking per picked per-day slot. Length 1 routes to bulkCreateBooking,
19
+ * length >=2 routes to createMultiServiceBooking.
20
+ */
21
+ bookings: Booking[];
22
+ /** Notification settings forwarded to the server. */
23
+ participantNotification?: ParticipantNotification;
24
+ /** Whether to send SMS reminder. */
25
+ sendSmsReminder: boolean;
26
+ }
27
+ /**
28
+ * Builds N Bookings from a DAY-range selection.
29
+ *
30
+ * The base Booking (service, resource, location, payment, participants) is
31
+ * produced by `buildBookingRequest` from the singular `timeSlot`; per-slot
32
+ * cloning then overrides only `bookedEntity.slot.startDate` / `endDate` from
33
+ * the multi-slot input.
34
+ *
35
+ * @throws if no service selection or no slots are available.
36
+ */
37
+ export declare function buildDayRangeBookingRequest(params: BookActionParams): BuildDayRangeBookingRequest;