@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.
- package/cjs/dist/__mocks__/booking/booking-client-service.js +4 -1
- package/cjs/dist/api/create-booking/index.d.ts +4 -4
- package/cjs/dist/api/create-bulk-booking/index.d.ts +54 -0
- package/cjs/dist/api/create-bulk-booking/index.js +54 -0
- package/cjs/dist/api/create-multi-service-booking/index.d.ts +53 -0
- package/cjs/dist/api/create-multi-service-booking/index.js +47 -0
- package/cjs/dist/api/index.d.ts +4 -1
- package/cjs/dist/api/index.js +32 -13
- package/cjs/dist/react/core/booking/Booking.d.ts +6 -1
- package/cjs/dist/react/core/booking/Booking.js +2 -0
- package/cjs/dist/services/booking/book-action/bookAction.js +39 -27
- package/cjs/dist/services/booking/book-action/buildBookingRequest.d.ts +1 -1
- package/cjs/dist/services/booking/book-action/buildBookingRequest.js +4 -2
- package/cjs/dist/services/booking/book-action/buildCartRequest.d.ts +20 -2
- package/cjs/dist/services/booking/book-action/buildCartRequest.js +24 -13
- package/cjs/dist/services/booking/book-action/buildDayRangeBookingRequest.d.ts +37 -0
- package/cjs/dist/services/booking/book-action/buildDayRangeBookingRequest.js +70 -0
- package/cjs/dist/services/booking/book-action/canBook.d.ts +2 -1
- package/cjs/dist/services/booking/book-action/canBook.js +4 -2
- package/cjs/dist/services/booking/book-action/createBookingsForCart.d.ts +22 -0
- package/cjs/dist/services/booking/book-action/createBookingsForCart.js +69 -0
- package/cjs/dist/services/booking/book-action/dayRange.d.ts +34 -0
- package/cjs/dist/services/booking/book-action/dayRange.js +43 -0
- package/cjs/dist/services/booking/book-action/index.d.ts +9 -6
- package/cjs/dist/services/booking/book-action/index.js +23 -13
- package/cjs/dist/services/booking/book-action/types.d.ts +15 -0
- package/cjs/dist/services/booking/booking.d.ts +31 -2
- package/cjs/dist/services/booking/booking.js +8 -0
- package/cjs/dist/services/index.d.ts +1 -1
- package/cjs/dist/services/index.js +6 -1
- package/cjs/dist/services/payment/payment.d.ts +4 -0
- package/cjs/dist/services/payment/payment.def.d.ts +6 -0
- package/cjs/dist/services/payment/payment.js +39 -17
- package/dist/__mocks__/booking/booking-client-service.js +4 -1
- package/dist/api/create-booking/index.d.ts +4 -4
- package/dist/api/create-bulk-booking/index.d.ts +54 -0
- package/dist/api/create-bulk-booking/index.js +51 -0
- package/dist/api/create-multi-service-booking/index.d.ts +53 -0
- package/dist/api/create-multi-service-booking/index.js +44 -0
- package/dist/api/index.d.ts +4 -1
- package/dist/api/index.js +3 -0
- package/dist/react/core/booking/Booking.d.ts +6 -1
- package/dist/react/core/booking/Booking.js +2 -0
- package/dist/services/booking/book-action/bookAction.js +34 -22
- package/dist/services/booking/book-action/buildBookingRequest.d.ts +1 -1
- package/dist/services/booking/book-action/buildBookingRequest.js +4 -2
- package/dist/services/booking/book-action/buildCartRequest.d.ts +20 -2
- package/dist/services/booking/book-action/buildCartRequest.js +23 -13
- package/dist/services/booking/book-action/buildDayRangeBookingRequest.d.ts +37 -0
- package/dist/services/booking/book-action/buildDayRangeBookingRequest.js +67 -0
- package/dist/services/booking/book-action/canBook.d.ts +2 -1
- package/dist/services/booking/book-action/canBook.js +4 -2
- package/dist/services/booking/book-action/createBookingsForCart.d.ts +22 -0
- package/dist/services/booking/book-action/createBookingsForCart.js +66 -0
- package/dist/services/booking/book-action/dayRange.d.ts +34 -0
- package/dist/services/booking/book-action/dayRange.js +39 -0
- package/dist/services/booking/book-action/index.d.ts +9 -6
- package/dist/services/booking/book-action/index.js +9 -6
- package/dist/services/booking/book-action/types.d.ts +15 -0
- package/dist/services/booking/booking.d.ts +31 -2
- package/dist/services/booking/booking.js +8 -0
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/payment/payment.d.ts +4 -0
- package/dist/services/payment/payment.def.d.ts +6 -0
- package/dist/services/payment/payment.js +39 -17
- package/package.json +2 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Builds the request payload(s) for a single APPOINTMENT service whose
|
|
4
|
+
* duration is configured as a DAY range.
|
|
5
|
+
*
|
|
6
|
+
* The slot list comes from availability — the user picks a start + end date
|
|
7
|
+
* and the picker emits one slot per day in `rangeTimeSlots`. The client just
|
|
8
|
+
* packages them as one Booking each. Routing is decided by `bookings.length`
|
|
9
|
+
* in `createBookingsForCart`:
|
|
10
|
+
* - length 1 -> `bulkCreateBooking`
|
|
11
|
+
* - length 2-8 -> `createMultiServiceBooking`
|
|
12
|
+
*
|
|
13
|
+
* The 8-day cap is enforced server-side; the builder does not gate on it.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.buildDayRangeBookingRequest = buildDayRangeBookingRequest;
|
|
17
|
+
const buildBookingRequest_js_1 = require("./buildBookingRequest.js");
|
|
18
|
+
/**
|
|
19
|
+
* Builds N Bookings from a DAY-range selection.
|
|
20
|
+
*
|
|
21
|
+
* The base Booking (service, resource, location, payment, participants) is
|
|
22
|
+
* produced by `buildBookingRequest` from the singular `timeSlot`; per-slot
|
|
23
|
+
* cloning then overrides only `bookedEntity.slot.startDate` / `endDate` from
|
|
24
|
+
* the multi-slot input.
|
|
25
|
+
*
|
|
26
|
+
* @throws if no service selection or no slots are available.
|
|
27
|
+
*/
|
|
28
|
+
function buildDayRangeBookingRequest(params) {
|
|
29
|
+
const item = params.serviceSelections[0];
|
|
30
|
+
if (!item) {
|
|
31
|
+
throw new Error('No service selection provided');
|
|
32
|
+
}
|
|
33
|
+
const slots = item.rangeTimeSlots && item.rangeTimeSlots.length > 0
|
|
34
|
+
? item.rangeTimeSlots
|
|
35
|
+
: item.timeSlot
|
|
36
|
+
? [item.timeSlot]
|
|
37
|
+
: [];
|
|
38
|
+
if (slots.length === 0) {
|
|
39
|
+
throw new Error('No time slot selected for service selection');
|
|
40
|
+
}
|
|
41
|
+
// Build the base Booking using the singular timeSlot path so that shared
|
|
42
|
+
// fields (service, resource, location, payment, participants) are derived
|
|
43
|
+
// exactly once and consistently. Each per-day Booking is then a shallow
|
|
44
|
+
// clone with only the slot start/end overridden from `slots[i]`.
|
|
45
|
+
const baseSelection = item.timeSlot ? item : { ...item, timeSlot: slots[0] };
|
|
46
|
+
const baseRequest = (0, buildBookingRequest_js_1.buildBookingRequest)({
|
|
47
|
+
...params,
|
|
48
|
+
serviceSelections: [baseSelection, ...params.serviceSelections.slice(1)],
|
|
49
|
+
});
|
|
50
|
+
const bookings = slots.map((slot) => ({
|
|
51
|
+
...baseRequest.booking,
|
|
52
|
+
bookedEntity: {
|
|
53
|
+
...baseRequest.booking.bookedEntity,
|
|
54
|
+
slot: {
|
|
55
|
+
...baseRequest.booking.bookedEntity?.slot,
|
|
56
|
+
startDate: slot.startDate,
|
|
57
|
+
endDate: slot.endDate,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
// TODO(createAsOneBooking): when the server flag lands, this builder should
|
|
62
|
+
// optionally collapse all slots into a single Booking spanning
|
|
63
|
+
// `slots[0].startDate -> slots[N-1].endDate` with `fullDay: true`, and
|
|
64
|
+
// routing should use plain `createBooking` (not bulk / multi-service).
|
|
65
|
+
return {
|
|
66
|
+
bookings,
|
|
67
|
+
participantNotification: baseRequest.participantNotification,
|
|
68
|
+
sendSmsReminder: baseRequest.sendSmsReminder ?? true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -14,7 +14,8 @@ export interface CanBookParams {
|
|
|
14
14
|
* Validates if booking can be executed
|
|
15
15
|
* Checks that all required data is present:
|
|
16
16
|
* - At least one service selection
|
|
17
|
-
* - Each service selection has a
|
|
17
|
+
* - Each service selection has either a `timeSlot` or a non-empty
|
|
18
|
+
* `rangeTimeSlots` (DAY-range path)
|
|
18
19
|
* - Form submission filled
|
|
19
20
|
*
|
|
20
21
|
* @param params - The booking data to validate
|
|
@@ -8,7 +8,8 @@ exports.canBook = canBook;
|
|
|
8
8
|
* Validates if booking can be executed
|
|
9
9
|
* Checks that all required data is present:
|
|
10
10
|
* - At least one service selection
|
|
11
|
-
* - Each service selection has a
|
|
11
|
+
* - Each service selection has either a `timeSlot` or a non-empty
|
|
12
|
+
* `rangeTimeSlots` (DAY-range path)
|
|
12
13
|
* - Form submission filled
|
|
13
14
|
*
|
|
14
15
|
* @param params - The booking data to validate
|
|
@@ -17,6 +18,7 @@ exports.canBook = canBook;
|
|
|
17
18
|
function canBook(params) {
|
|
18
19
|
const { serviceSelections, formSubmission } = params;
|
|
19
20
|
return (serviceSelections.length > 0 &&
|
|
20
|
-
serviceSelections.every((item) => item.timeSlot !== undefined
|
|
21
|
+
serviceSelections.every((item) => item.timeSlot !== undefined ||
|
|
22
|
+
(item.rangeTimeSlots !== undefined && item.rangeTimeSlots.length > 0)) &&
|
|
21
23
|
formSubmission !== null);
|
|
22
24
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the booking(s) needed for cart construction.
|
|
3
|
+
*
|
|
4
|
+
* Branches on the service selection:
|
|
5
|
+
* - DAY-range path with 1 picked slot -> `bulkCreateBooking`
|
|
6
|
+
* - DAY-range path with 2..8 picked slots -> `createMultiServiceBooking`
|
|
7
|
+
* - default path -> `createBooking`
|
|
8
|
+
*
|
|
9
|
+
* All branches return the same shape so `executeBookAction` can stay
|
|
10
|
+
* branchless from cart-creation onwards. Cart construction reads each
|
|
11
|
+
* single-service booking ID — per SDK guidance, never the
|
|
12
|
+
* `multiServiceBooking._id`.
|
|
13
|
+
*/
|
|
14
|
+
import type { ContactDetails } from '@wix/auto_sdk_bookings_bookings';
|
|
15
|
+
import type { BookActionParams } from './types.js';
|
|
16
|
+
export interface CreatedBookings {
|
|
17
|
+
/** One ID per single-service booking. >=1 on success. */
|
|
18
|
+
bookingIds: string[];
|
|
19
|
+
/** Canonical contact details echoed by the server (read from the first booking). */
|
|
20
|
+
contactDetails?: ContactDetails;
|
|
21
|
+
}
|
|
22
|
+
export declare function createBookingsForCart(params: BookActionParams): Promise<CreatedBookings>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the booking(s) needed for cart construction.
|
|
4
|
+
*
|
|
5
|
+
* Branches on the service selection:
|
|
6
|
+
* - DAY-range path with 1 picked slot -> `bulkCreateBooking`
|
|
7
|
+
* - DAY-range path with 2..8 picked slots -> `createMultiServiceBooking`
|
|
8
|
+
* - default path -> `createBooking`
|
|
9
|
+
*
|
|
10
|
+
* All branches return the same shape so `executeBookAction` can stay
|
|
11
|
+
* branchless from cart-creation onwards. Cart construction reads each
|
|
12
|
+
* single-service booking ID — per SDK guidance, never the
|
|
13
|
+
* `multiServiceBooking._id`.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.createBookingsForCart = createBookingsForCart;
|
|
17
|
+
const index_js_1 = require("../../../api/create-booking/index.js");
|
|
18
|
+
const index_js_2 = require("../../../api/create-bulk-booking/index.js");
|
|
19
|
+
const index_js_3 = require("../../../api/create-multi-service-booking/index.js");
|
|
20
|
+
const buildBookingRequest_js_1 = require("./buildBookingRequest.js");
|
|
21
|
+
const buildDayRangeBookingRequest_js_1 = require("./buildDayRangeBookingRequest.js");
|
|
22
|
+
const dayRange_js_1 = require("./dayRange.js");
|
|
23
|
+
async function createBookingsForCart(params) {
|
|
24
|
+
const firstSelection = params.serviceSelections[0];
|
|
25
|
+
if (!firstSelection) {
|
|
26
|
+
throw new Error('No service selection provided');
|
|
27
|
+
}
|
|
28
|
+
if ((0, dayRange_js_1.isDayRangeService)(firstSelection.service)) {
|
|
29
|
+
const req = (0, buildDayRangeBookingRequest_js_1.buildDayRangeBookingRequest)(params);
|
|
30
|
+
// TODO(createAsOneBooking): when the server flag lands, branch here:
|
|
31
|
+
// if (createAsOneBooking) -> createBooking({ ...wideRange, fullDay: true })
|
|
32
|
+
// collapsing all slots into one combined Booking. Until then, we always
|
|
33
|
+
// use one Booking per picked slot.
|
|
34
|
+
if (req.bookings.length === 1) {
|
|
35
|
+
const response = await (0, index_js_2.bulkCreateBooking)([{ booking: req.bookings[0] }], {
|
|
36
|
+
participantNotification: req.participantNotification,
|
|
37
|
+
sendSmsReminder: req.sendSmsReminder,
|
|
38
|
+
});
|
|
39
|
+
const results = response.results ?? [];
|
|
40
|
+
return {
|
|
41
|
+
bookingIds: results.map((r) => r.item?._id).filter(Boolean),
|
|
42
|
+
// All N daily bookings share the same customer; read from the first.
|
|
43
|
+
contactDetails: results[0]?.item?.contactDetails,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const response = await (0, index_js_3.createMultiServiceBooking)(req.bookings, {
|
|
47
|
+
participantNotification: req.participantNotification,
|
|
48
|
+
sendSmsReminder: req.sendSmsReminder,
|
|
49
|
+
});
|
|
50
|
+
const bookings = response.multiServiceBooking?.bookings ?? [];
|
|
51
|
+
return {
|
|
52
|
+
bookingIds: bookings
|
|
53
|
+
.map((b) => b.booking?._id)
|
|
54
|
+
.filter(Boolean),
|
|
55
|
+
contactDetails: bookings[0]?.booking?.contactDetails,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const createBookingRequest = (0, buildBookingRequest_js_1.buildBookingRequest)(params);
|
|
59
|
+
const bookingResponse = await (0, index_js_1.createBooking)(createBookingRequest.booking, {
|
|
60
|
+
participantNotification: createBookingRequest.participantNotification,
|
|
61
|
+
sendSmsReminder: createBookingRequest.sendSmsReminder,
|
|
62
|
+
formSubmission: createBookingRequest.formSubmission,
|
|
63
|
+
});
|
|
64
|
+
const bookingId = bookingResponse.booking?._id;
|
|
65
|
+
return {
|
|
66
|
+
bookingIds: bookingId ? [bookingId] : [],
|
|
67
|
+
contactDetails: bookingResponse.booking?.contactDetails,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAY-range service helpers.
|
|
3
|
+
*
|
|
4
|
+
* APPOINTMENT services whose schedule has a `durationRange` with
|
|
5
|
+
* `unitType === DAY` route through the per-day slot path:
|
|
6
|
+
* - 1 picked slot -> `bulkCreateBooking`
|
|
7
|
+
* - 2..8 picked slots -> `createMultiServiceBooking`
|
|
8
|
+
*
|
|
9
|
+
* CLASS/COURSE selections and HOUR-range / fixed-duration APPOINTMENT
|
|
10
|
+
* selections keep using the existing `createBooking` path.
|
|
11
|
+
*/
|
|
12
|
+
import { type Service } from '@wix/auto_sdk_bookings_services';
|
|
13
|
+
/**
|
|
14
|
+
* Returns true when the given service is an APPOINTMENT whose duration is
|
|
15
|
+
* configured as a DAY range. Useful at the UI layer (e.g. routing) to know
|
|
16
|
+
* before a slot has been picked whether the selection will go through the
|
|
17
|
+
* DAY-range create path.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isDayRangeService(service: Service): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Bounds (in days) that a customer may pick for a DAY-range service.
|
|
22
|
+
* Both bounds are inclusive. The server enforces 1..8 per `DailyConfig` (SDK);
|
|
23
|
+
* this helper just exposes whatever the configured values are.
|
|
24
|
+
*/
|
|
25
|
+
export type DayRangeBounds = {
|
|
26
|
+
min: number;
|
|
27
|
+
max: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Returns the configured min/max day bounds for a DAY-range service, or
|
|
31
|
+
* `null` if the service is not DAY-range. Falls back to `min = 1` / `max = min`
|
|
32
|
+
* when the service is missing `dayOptions` configuration values.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getDayRangeBounds(service: Service): DayRangeBounds | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DAY-range service helpers.
|
|
4
|
+
*
|
|
5
|
+
* APPOINTMENT services whose schedule has a `durationRange` with
|
|
6
|
+
* `unitType === DAY` route through the per-day slot path:
|
|
7
|
+
* - 1 picked slot -> `bulkCreateBooking`
|
|
8
|
+
* - 2..8 picked slots -> `createMultiServiceBooking`
|
|
9
|
+
*
|
|
10
|
+
* CLASS/COURSE selections and HOUR-range / fixed-duration APPOINTMENT
|
|
11
|
+
* selections keep using the existing `createBooking` path.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.isDayRangeService = isDayRangeService;
|
|
15
|
+
exports.getDayRangeBounds = getDayRangeBounds;
|
|
16
|
+
const auto_sdk_bookings_services_1 = require("@wix/auto_sdk_bookings_services");
|
|
17
|
+
/**
|
|
18
|
+
* Returns true when the given service is an APPOINTMENT whose duration is
|
|
19
|
+
* configured as a DAY range. Useful at the UI layer (e.g. routing) to know
|
|
20
|
+
* before a slot has been picked whether the selection will go through the
|
|
21
|
+
* DAY-range create path.
|
|
22
|
+
*/
|
|
23
|
+
function isDayRangeService(service) {
|
|
24
|
+
const isAppointment = service.type === auto_sdk_bookings_services_1.ServiceType.APPOINTMENT;
|
|
25
|
+
const isDayRange = service.schedule?.availabilityConstraints?.durationRange?.unitType ===
|
|
26
|
+
auto_sdk_bookings_services_1.UnitType.DAY;
|
|
27
|
+
return isAppointment && isDayRange;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the configured min/max day bounds for a DAY-range service, or
|
|
31
|
+
* `null` if the service is not DAY-range. Falls back to `min = 1` / `max = min`
|
|
32
|
+
* when the service is missing `dayOptions` configuration values.
|
|
33
|
+
*/
|
|
34
|
+
function getDayRangeBounds(service) {
|
|
35
|
+
if (!isDayRangeService(service))
|
|
36
|
+
return null;
|
|
37
|
+
const dayOptions = service.schedule?.availabilityConstraints?.durationRange?.dayOptions;
|
|
38
|
+
const min = dayOptions?.minDurationInDays ?? 1;
|
|
39
|
+
const max = dayOptions?.maxDurationInDays ?? min;
|
|
40
|
+
if (max < min)
|
|
41
|
+
return null;
|
|
42
|
+
return { min, max };
|
|
43
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Book Action - Exports
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
4
|
+
export * from './bookAction.js';
|
|
5
|
+
export * from './canBook.js';
|
|
6
|
+
export * from './buildBookingRequest.js';
|
|
7
|
+
export * from './buildDayRangeBookingRequest.js';
|
|
8
|
+
export * from './buildCartRequest.js';
|
|
9
|
+
export * from './createBookingsForCart.js';
|
|
10
|
+
export * from './dayRange.js';
|
|
11
|
+
export * from './isCheckoutRequired.js';
|
|
12
|
+
export * from './types.js';
|
|
@@ -2,17 +2,27 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Book Action - Exports
|
|
4
4
|
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
5
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var isCheckoutRequired_js_1 = require("./isCheckoutRequired.js");
|
|
16
|
-
Object.defineProperty(exports, "isCheckoutRequired", { enumerable: true, get: function () { return isCheckoutRequired_js_1.isCheckoutRequired; } });
|
|
17
|
-
var types_js_1 = require("./types.js");
|
|
18
|
-
Object.defineProperty(exports, "BookResultType", { enumerable: true, get: function () { return types_js_1.BookResultType; } });
|
|
20
|
+
__exportStar(require("./bookAction.js"), exports);
|
|
21
|
+
__exportStar(require("./canBook.js"), exports);
|
|
22
|
+
__exportStar(require("./buildBookingRequest.js"), exports);
|
|
23
|
+
__exportStar(require("./buildDayRangeBookingRequest.js"), exports);
|
|
24
|
+
__exportStar(require("./buildCartRequest.js"), exports);
|
|
25
|
+
__exportStar(require("./createBookingsForCart.js"), exports);
|
|
26
|
+
__exportStar(require("./dayRange.js"), exports);
|
|
27
|
+
__exportStar(require("./isCheckoutRequired.js"), exports);
|
|
28
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
import type { ServiceSelection } from '../booking.js';
|
|
5
5
|
import type { FormValues } from '@wix/forms/components';
|
|
6
6
|
import type { Location as TimeSlotLocationType } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
7
|
+
import type { SelectedPaymentOptionWithLiterals } from '@wix/auto_sdk_bookings_bookings';
|
|
8
|
+
/**
|
|
9
|
+
* Narrowed booking-API `selectedPaymentOption` to the two values a consumer
|
|
10
|
+
* can pick in the UI. Derived from the SDK enum (`SelectedPaymentOption`) so
|
|
11
|
+
* the type stays in sync; MEMBERSHIP variants are intentionally excluded
|
|
12
|
+
* because they require pricing-plan plumbing not exposed here.
|
|
13
|
+
*/
|
|
14
|
+
export type SelectedPaymentOption = Extract<SelectedPaymentOptionWithLiterals, 'ONLINE' | 'OFFLINE'>;
|
|
7
15
|
/**
|
|
8
16
|
* Enum for book result types
|
|
9
17
|
*/
|
|
@@ -38,6 +46,13 @@ export interface BookActionParams {
|
|
|
38
46
|
timezone?: string;
|
|
39
47
|
/** Optional app ID override for the catalog reference. Defaults to the bookings app ID. */
|
|
40
48
|
appId?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Optional consumer-selected payment option. When provided, overrides the
|
|
51
|
+
* heuristic derived from `service.payment.options` in `buildBookingRequest`
|
|
52
|
+
* and matches the line item's `paymentOption` produced by the payment
|
|
53
|
+
* service. When omitted, the existing service-config heuristic applies.
|
|
54
|
+
*/
|
|
55
|
+
selectedPaymentOption?: SelectedPaymentOption;
|
|
41
56
|
}
|
|
42
57
|
/**
|
|
43
58
|
* Props passed to children of Book component
|
|
@@ -7,7 +7,8 @@ import { type Signal } from '@wix/services-definitions/core-services/signals';
|
|
|
7
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
|
-
import type { BookResult } from './book-action/types.js';
|
|
10
|
+
import type { BookResult, SelectedPaymentOption } from './book-action/types.js';
|
|
11
|
+
export type { SelectedPaymentOption } from './book-action/types.js';
|
|
11
12
|
/**
|
|
12
13
|
* Extended Resource type with a type field for categorization
|
|
13
14
|
*/
|
|
@@ -40,8 +41,18 @@ export interface ServiceSelection {
|
|
|
40
41
|
service: Service;
|
|
41
42
|
/** Selected resources (staff members, rooms, etc.) with type information */
|
|
42
43
|
resources: ExtendedResource[];
|
|
43
|
-
/** Per-item time slot data */
|
|
44
|
+
/** Per-item time slot data (single-slot path; existing behavior). */
|
|
44
45
|
timeSlot?: ServiceSelectionTimeSlot;
|
|
46
|
+
/**
|
|
47
|
+
* Per-day slots for DAY-range services. Populated by the availability
|
|
48
|
+
* picker after the customer picks a start + end date: one entry per day
|
|
49
|
+
* in the picked range. When set, supersedes `timeSlot` for the DAY-range
|
|
50
|
+
* builder, which produces one Booking per entry and routes via length:
|
|
51
|
+
* - 1 -> bulkCreateBooking
|
|
52
|
+
* - 2-8 -> createMultiServiceBooking
|
|
53
|
+
* Optional & additive: existing single-slot callers stay on `timeSlot`.
|
|
54
|
+
*/
|
|
55
|
+
rangeTimeSlots?: ServiceSelectionTimeSlot[];
|
|
45
56
|
/** Number of participants for this service selection */
|
|
46
57
|
totalParticipants?: number;
|
|
47
58
|
}
|
|
@@ -70,6 +81,13 @@ export interface BookingServiceActions {
|
|
|
70
81
|
setTimezone(timezone: string): void;
|
|
71
82
|
setFormSubmission(values: FormValues | null): void;
|
|
72
83
|
clearFormSubmission(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Set (or clear with `null`) the consumer-selected payment option. When set
|
|
86
|
+
* to `'ONLINE'` or `'OFFLINE'`, this overrides the service-config heuristic
|
|
87
|
+
* used by `book()` and the payment preview. When set to `null`, the override
|
|
88
|
+
* is cleared and the heuristic applies again.
|
|
89
|
+
*/
|
|
90
|
+
setSelectedPaymentOption(value: SelectedPaymentOption | null): void;
|
|
73
91
|
clearAll(): void;
|
|
74
92
|
book(): Promise<BookResult>;
|
|
75
93
|
}
|
|
@@ -86,6 +104,12 @@ export interface BookingService {
|
|
|
86
104
|
timezone: Signal<string | undefined>;
|
|
87
105
|
/** Signal containing the form submission */
|
|
88
106
|
formSubmission: Signal<FormValues | null>;
|
|
107
|
+
/**
|
|
108
|
+
* Signal containing the consumer-selected payment option. `undefined` means
|
|
109
|
+
* "not chosen" — `book()` and the payment preview fall back to the
|
|
110
|
+
* service-config heuristic. Set to `'ONLINE'` or `'OFFLINE'` to override.
|
|
111
|
+
*/
|
|
112
|
+
selectedPaymentOption: Signal<SelectedPaymentOption | undefined>;
|
|
89
113
|
/** Actions for modifying booking state */
|
|
90
114
|
actions: BookingServiceActions;
|
|
91
115
|
}
|
|
@@ -110,6 +134,11 @@ export interface BookingServiceConfig {
|
|
|
110
134
|
timezone?: string;
|
|
111
135
|
/** Optional initial form submission */
|
|
112
136
|
formSubmission?: FormValues | null;
|
|
137
|
+
/**
|
|
138
|
+
* Optional initial consumer-selected payment option. Omit to use the
|
|
139
|
+
* service-config heuristic; set to `'ONLINE'` or `'OFFLINE'` to override.
|
|
140
|
+
*/
|
|
141
|
+
selectedPaymentOption?: SelectedPaymentOption;
|
|
113
142
|
/** Optional app ID override for the catalog reference. Defaults to the bookings app ID. */
|
|
114
143
|
appId?: string;
|
|
115
144
|
}
|
|
@@ -73,6 +73,7 @@ exports.BookingService = services_definitions_1.implementService.withConfig()(ex
|
|
|
73
73
|
const locationSignal = signalsService.signal(config.location || null);
|
|
74
74
|
const timezoneSignal = signalsService.signal(config.timezone ?? getClientTimezone());
|
|
75
75
|
const formSubmissionSignal = signalsService.signal(config.formSubmission || null);
|
|
76
|
+
const selectedPaymentOptionSignal = signalsService.signal(config.selectedPaymentOption);
|
|
76
77
|
// ========================================================================
|
|
77
78
|
// Helpers
|
|
78
79
|
// ========================================================================
|
|
@@ -167,6 +168,10 @@ exports.BookingService = services_definitions_1.implementService.withConfig()(ex
|
|
|
167
168
|
clearFormSubmission() {
|
|
168
169
|
formSubmissionSignal.set(null);
|
|
169
170
|
},
|
|
171
|
+
// Payment option action
|
|
172
|
+
setSelectedPaymentOption(value) {
|
|
173
|
+
selectedPaymentOptionSignal.set(value ?? undefined);
|
|
174
|
+
},
|
|
170
175
|
// Clear all
|
|
171
176
|
clearAll() {
|
|
172
177
|
this.clearItems();
|
|
@@ -180,6 +185,7 @@ exports.BookingService = services_definitions_1.implementService.withConfig()(ex
|
|
|
180
185
|
const formSubmission = formSubmissionSignal.get();
|
|
181
186
|
const location = locationSignal.get();
|
|
182
187
|
const timezone = timezoneSignal.get();
|
|
188
|
+
const selectedPaymentOption = selectedPaymentOptionSignal.get();
|
|
183
189
|
// Validation happens inside executeBookAction
|
|
184
190
|
return (0, bookAction_js_1.executeBookAction)({
|
|
185
191
|
serviceSelections,
|
|
@@ -187,6 +193,7 @@ exports.BookingService = services_definitions_1.implementService.withConfig()(ex
|
|
|
187
193
|
location,
|
|
188
194
|
timezone,
|
|
189
195
|
appId: config.appId,
|
|
196
|
+
selectedPaymentOption,
|
|
190
197
|
});
|
|
191
198
|
},
|
|
192
199
|
};
|
|
@@ -195,6 +202,7 @@ exports.BookingService = services_definitions_1.implementService.withConfig()(ex
|
|
|
195
202
|
location: locationSignal,
|
|
196
203
|
timezone: timezoneSignal,
|
|
197
204
|
formSubmission: formSubmissionSignal,
|
|
205
|
+
selectedPaymentOption: selectedPaymentOptionSignal,
|
|
198
206
|
actions,
|
|
199
207
|
};
|
|
200
208
|
});
|
|
@@ -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, buildCartRequest, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCartParams, } from './booking/book-action/index.js';
|
|
10
|
+
export { executeBookAction, canBook, buildBookingRequest, buildCartRequest, buildDayRangeCartRequest, buildDayRangeBookingRequest, createBookingsForCart, isDayRangeService, getDayRangeBounds, type CanBookParams, type BookResult, type BookingError, type BookActionParams, type BookChildProps, type BookProps, type BuildCartParams, type BuildDayRangeCartParams, type BuildDayRangeBookingRequest, type CreatedBookings, type DayRangeBounds, } 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.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;
|
|
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.getDayRangeBounds = exports.isDayRangeService = exports.createBookingsForCart = exports.buildDayRangeBookingRequest = exports.buildDayRangeCartRequest = 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; } });
|
|
@@ -31,6 +31,11 @@ Object.defineProperty(exports, "executeBookAction", { enumerable: true, get: fun
|
|
|
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
33
|
Object.defineProperty(exports, "buildCartRequest", { enumerable: true, get: function () { return index_js_3.buildCartRequest; } });
|
|
34
|
+
Object.defineProperty(exports, "buildDayRangeCartRequest", { enumerable: true, get: function () { return index_js_3.buildDayRangeCartRequest; } });
|
|
35
|
+
Object.defineProperty(exports, "buildDayRangeBookingRequest", { enumerable: true, get: function () { return index_js_3.buildDayRangeBookingRequest; } });
|
|
36
|
+
Object.defineProperty(exports, "createBookingsForCart", { enumerable: true, get: function () { return index_js_3.createBookingsForCart; } });
|
|
37
|
+
Object.defineProperty(exports, "isDayRangeService", { enumerable: true, get: function () { return index_js_3.isDayRangeService; } });
|
|
38
|
+
Object.defineProperty(exports, "getDayRangeBounds", { enumerable: true, get: function () { return index_js_3.getDayRangeBounds; } });
|
|
34
39
|
var booking_form_js_1 = require("./booking-form/booking-form.js");
|
|
35
40
|
Object.defineProperty(exports, "BookingFormService", { enumerable: true, get: function () { return booking_form_js_1.BookingFormService; } });
|
|
36
41
|
Object.defineProperty(exports, "BookingFormServiceDefinition", { enumerable: true, get: function () { return booking_form_js_1.BookingFormServiceDefinition; } });
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Supports two modes: SSR (config with pre-fetched data) and lazy loading (reactive)
|
|
5
5
|
*/
|
|
6
6
|
import { type PaymentServiceConfig, type PaymentServiceInternalConfig, type PricingServiceSelection } from './payment.def.js';
|
|
7
|
+
import type { SelectedPaymentOption } from '../booking/book-action/types.js';
|
|
7
8
|
export { PaymentServiceDefinition, type PaymentServiceConfig, type PaymentDetails, type LineItemAdditionalInfo, type PricingServiceSelection, type ServicePaymentOptions, } from './payment.def.js';
|
|
8
9
|
export type { PaymentServiceAPI, PaymentServiceInternalConfig, } from './payment.def.js';
|
|
9
10
|
export declare const PaymentService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
@@ -25,8 +26,11 @@ export type ErrorPaymentConfigResult = {
|
|
|
25
26
|
*
|
|
26
27
|
* @param params.pricingServiceSelections - Pricing service selections for calculation
|
|
27
28
|
* @param params.totalParticipants - Number of participants (default: 1)
|
|
29
|
+
* @param params.selectedPaymentOption - Optional consumer-selected payment option;
|
|
30
|
+
* overrides the service-config heuristic on each line item's `paymentOption`.
|
|
28
31
|
*/
|
|
29
32
|
export declare function loadPaymentConfig(params: {
|
|
30
33
|
pricingServiceSelections: PricingServiceSelection[];
|
|
31
34
|
totalParticipants?: number;
|
|
35
|
+
selectedPaymentOption?: SelectedPaymentOption;
|
|
32
36
|
}): Promise<SuccessPaymentConfigResult | ErrorPaymentConfigResult>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { Signal } from '@wix/services-definitions/core-services/signals';
|
|
6
6
|
import type { CalculateTotalsResponse } from '@wix/auto_sdk_ecom_totals-calculator';
|
|
7
7
|
import type { Service } from '@wix/auto_sdk_bookings_services';
|
|
8
|
+
import type { SelectedPaymentOption } from '../booking/book-action/types.js';
|
|
8
9
|
/**
|
|
9
10
|
* Service payment options derived from service.payment.options.
|
|
10
11
|
* Describes which payment methods the service supports.
|
|
@@ -74,6 +75,11 @@ export interface PaymentServiceInternalConfig extends PaymentServiceConfig {
|
|
|
74
75
|
pricingServiceSelections?: PricingServiceSelection[];
|
|
75
76
|
/** Number of participants for lazy loading (internal use) */
|
|
76
77
|
totalParticipants?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Optional consumer-selected payment option used for lazy loading. When
|
|
80
|
+
* set, overrides the service-config heuristic in line item `paymentOption`.
|
|
81
|
+
*/
|
|
82
|
+
selectedPaymentOption?: SelectedPaymentOption;
|
|
77
83
|
}
|
|
78
84
|
export interface PaymentServiceAPI {
|
|
79
85
|
paymentDetailsSignal: Signal<PaymentDetails | null>;
|